I want to display the text a&b
in my LinkLabel.Text
.
linkLabel1.Text = "a&b";
This displays:
ab
If I change the code to:
linkLabel1.Text = "a&&b";
one &
sign will show.
a&b
Is this the correct way to print one ampersand?
&
is a shortcut key from winforms controls.
"a&b"
means; shortcut key for alt+b
Check out: Create Access Keys for Windows Forms Controls
To include an ampersand in a caption without creating an access key, include two ampersands (&&). A single ampersand is displayed in the caption and no characters are underlined.
// Set the letter "P" as an access key.
button1.Text = "&Print";
Also I found Label.UseMnemonic
property.
Gets or sets a value indicating whether the control interprets an ampersand character (&) in the control's Text property to be an access key prefix character.