windows 如何在按钮或标签文本中显示“&”(与号)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7601617/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:47:15  来源:igfitidea点击:

How can I show an "&" (ampersand) in button or label text?

vb.netwindowsms-access

提问by atrueresistance

I would like to show the &character, notthe keyboard shortcut in the text property of a button or label.

我想在按钮或标签的文本属性中显示&字符,而不是键盘快捷键。

Is there a way to do this?

有没有办法做到这一点?

回答by Bala R

If you are trying to display &in button text, use &&. A single &is used for keyboard shortcuts, and a double ampersand will escape that.

如果您尝试&在按钮文本中显示,请使用&&. 单个&用于键盘快捷键,而双 & 号将避开它。

The article Escape ampersand (&) character in C#mentions that you can leave the caption unaltered with single &and just set UseMnemonicproperty of the button to false.

文章Expedition在C#号(&)字符提到,你可以离开的标题不变单&,只是设置UseMnemonic按钮的属性false

回答by Rashmi

Try double &(&&). It works with VBA code.

尝试双&( &&)。它适用于 VBA 代码。