微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.jb51.cc/csharp/98052.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐