Stop ampersand from turning into mnemonics / accelerators for binding Windows Forms

Possible duplicate:
Type "&" Character in Text Shortcut in Windows Forms?

On the screen with label controls related to user-filled properties, I get underlined characters (mnemonics) on the label, because the underlying data contains ampersands.

For example, if the related property contains โ€œA & B Truckingโ€, then โ€œAB Truckingโ€ is displayed on the label with an underlined B. Alt-B on the keyboard will focus this label.

How do you prevent this with related controls?

+3
c # winforms binding
Feb 01 '12 at 17:45
source share
4 answers

You can prevent this by either doubled on 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

+9
Feb 01 2018-12-01T00:
source share

Depending on the situation, you can either set UseMnemonic to false on the corresponding control (for example, with data binding) OR a double ampersand (and thus avoiding it). For passage see this .

+4
Feb 01 '12 at 17:50
source share

Set the UseMnemonic label UseMnemonic to false .

+3
Feb 01 '12 at 17:51
source share

Instead, you can use A&&B Trucking .

-one
Feb 01 2018-12-01T00:
source share



All Articles