Stop ampersand from being turned into a mnemonic/accelerators for Windows Forms binding [duplicate]

情到浓时终转凉″ 提交于 2019-12-23 20:43:50

问题


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

On a screen with label controls bound to user-filled properties, I'm getting underlined characters (mnemonics) on the label because the underlying data contains ampersands.

For example, if the bound property contains "A&B Trucking", then the label shows as "AB Trucking" with the B underlined. Alt-B on the keyboard would focus that label.

How do you prevent this from happening with bound controls?


回答1:


You can prevent this by either doubling up on the ampersands (&& will display correctly as &), or you can set the UseMnemonic property of the label to false which is probably the best solution in your case




回答2:


Depending on the situation you can either set UseMnemonic to false on the respective control (works for example with databinding) OR double the ampersand (and thus escaping it). For a walkthrough see this.




回答3:


Set the label's UseMnemonic property to false.




回答4:


You can use A&&B Trucking instead.



来源:https://stackoverflow.com/questions/9100607/stop-ampersand-from-being-turned-into-a-mnemonic-accelerators-for-windows-forms

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