Set Mnemonic To A Control In Visual Studio

Do you know what mnemonics are? Those are short underlines below an alphabet character usually found on labels. Usually when you press the key ALT together with the said letter, if the mnemonic is inside a button, the button gets pushed, the same result as when you click on that same button using a mouse. To activate this, we use the character & (ampersand) beside the letter. Simple as that. In Visual Studio, just go to the control’s properties and look for the Text property.

But what if we set a mnemonic to a Label so that when the key combination is activated, the focus goes to a TextBox. You do the same thing you do with the button’s label. Add an & character beside the letter. To link the Label and the TextBox, the TabIndex of the Label must be – 1 (minus 1) than the TabIndex of the TextBox. This is how it works in Visual Studio unlike Java where you use a method to set the component that the Label‘s mnemonic will focus on. You can find TabIndex part within the properties of the Control.

Related Posts Plugin for WordPress, Blogger...

Leave a Reply

Your email address will not be published. Required fields are marked *