Enter “&” symbol into a text Label in Windows Forms?

◇◆丶佛笑我妖孽 提交于 2019-11-26 12:23:51

Two ways:

  • Escape it with another ampersand (&&).

  • Set UseMnemonic for that label to false. This causes all ampersands within the text to be taken literally so you don't need to double any of them. You'll lose the underlining and access key features though.

    You can set the value either in the designer, or in code:

    myLabel.UseMnemonic = false;
    myLabel.Text = "Text&Text";
    

Add another ampersand in front of it, so: &&

Or have a look at the following: Label.UseMnemonic (MSDN documentation)

You can escape & by adding it two times, to try &&.

I don't know how to use '&' in the designer, but in the code you can use '&&' for showing one '&'

Adel El Biari

Try this:

((char)0x26).ToString()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!