加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 18:17:12 所属栏目:百科 来源:网络整理
导读:参见英文答案 Enter “” symbol into a text Label in Windows Forms?5个 考虑: Label label = new Label();label.Text = ""; 但是……在我运行程序之后,我看不到amp ;, 如何在标签中显示该字符? 我想只显示角色. 安培; 解决方法 那是因为在标签,按钮和菜
参见英文答案 > 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&&,正如其他几个答案所提到的那样.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读