问题
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