c# – 为什么不显示在Windows窗体标签中?

前端之家收集整理的这篇文章主要介绍了c# – 为什么不显示在Windows窗体标签中?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
参见英文答案 > Enter “&” symbol into a text Label in Windows Forms?5个
考虑:
Label label = new Label();

label.Text = "&";

但是……在我运行程序之后,我看不到&amp ;,

如何在标签显示该字符?

我想只显示角色. &安培;

解决方法

那是因为&在标签,按钮和菜单添加前缀以访问关键字符,即可以使用Alt按下这些字符以直接为控件提供焦点.
label1.UseMnemonic = false;

将摆脱这种行为.

UseMnemonic的文档:

true if the label doesn’t display the ampersand character and underlines the character after the ampersand in its displayed text and treats the underlined character as an access key; otherwise,false if the ampersand character is displayed in the text of the control. The default is true.

如果你需要显示&和访问键的行为,那么你需要逃避& as&&,正如其他几个答案所提到的那样.

原文链接:https://www.f2er.com/csharp/98052.html

猜你在找的C#相关文章