Label.UseMnemonic Vlastnost
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Získá nebo nastaví hodnotu určující, zda ovládací prvek interpretuje ampersand znak (&) ve vlastnosti ovládacího prvku Text jako znak předpony přístupového klíče.
public:
property bool UseMnemonic { bool get(); void set(bool value); };
public bool UseMnemonic { get; set; }
member this.UseMnemonic : bool with get, set
Public Property UseMnemonic As Boolean
Hodnota vlastnosti
true Pokud popisek nezobrazuje znak ampersand a podtrhuje znak za ampersandem v zobrazeném textu a považuje podtržený znak za přístupovým klíčem; v opačném případě, false pokud je znak ampersand zobrazen v textu ovládacího prvku. Výchozí hodnota je true.
Příklady
Následující příklad kódu ukazuje, jak vytvořit Label ovládací prvek, který má trojrozměrné ohraničení a obrázek zobrazený pomocí ImageList a ImageIndex vlastnosti. Ovládací prvek má také titulek se zadaným mnemónickým znakem. Ukázkový kód používá PreferredHeight a PreferredWidth vlastnosti k správné velikosti Label ovládacího prvku ve formuláři, na kterém je zobrazen. Tento příklad vyžaduje ImageList vytvoření a pojmenování imageList1 a načtení dvou imagí. Příklad také vyžaduje, aby kód byl ve formuláři, který má System.Drawing obor názvů přidaný do jeho kódu.
public:
void CreateMyLabel()
{
// Create an instance of a Label.
Label^ label1 = gcnew Label;
// Set the border to a three-dimensional border.
label1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
// Set the ImageList to use for displaying an image.
label1->ImageList = imageList1;
// Use the second image in imageList1.
label1->ImageIndex = 1;
// Align the image to the top left corner.
label1->ImageAlign = ContentAlignment::TopLeft;
// Specify that the text can display mnemonic characters.
label1->UseMnemonic = true;
// Set the text of the control and specify a mnemonic character.
label1->Text = "First &Name:";
/* Set the size of the control based on the PreferredHeight and PreferredWidth values. */
label1->Size = System::Drawing::Size( label1->PreferredWidth, label1->PreferredHeight );
//...Code to add the control to the form...
}
public void CreateMyLabel()
{
// Create an instance of a Label.
Label label1 = new Label();
// Set the border to a three-dimensional border.
label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
// Set the ImageList to use for displaying an image.
label1.ImageList = imageList1;
// Use the second image in imageList1.
label1.ImageIndex = 1;
// Align the image to the top left corner.
label1.ImageAlign = ContentAlignment.TopLeft;
// Specify that the text can display mnemonic characters.
label1.UseMnemonic = true;
// Set the text of the control and specify a mnemonic character.
label1.Text = "First &Name:";
/* Set the size of the control based on the PreferredHeight and PreferredWidth values. */
label1.Size = new Size (label1.PreferredWidth, label1.PreferredHeight);
//...Code to add the control to the form...
}
Public Sub CreateMyLabel()
' Create an instance of a Label.
Dim label1 As New Label()
' Set the border to a three-dimensional border.
label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
' Set the ImageList to use for displaying an image.
label1.ImageList = imageList1
' Use the second image in imageList1.
label1.ImageIndex = 1
' Align the image to the top left corner.
label1.ImageAlign = ContentAlignment.TopLeft
' Specify that the text can display mnemonic characters.
label1.UseMnemonic = True
' Set the text of the control and specify a mnemonic character.
label1.Text = "First &Name:"
' Set the size of the control based on the PreferredHeight and PreferredWidth values.
label1.Size = New Size(label1.PreferredWidth, label1.PreferredHeight)
'...Code to add the control to the form...
End Sub
Poznámky
UseMnemonic Pokud je vlastnost nastavena na true a mnemónní znak (znak před ampersand) je definován ve Text vlastnosti Label, stisknutím alt+ měmonic znak nastaví fokus na ovládací prvek, který následuje Label v pořadí ovládacích prvků. Pomocí této vlastnosti můžete poskytnout správnou navigaci pomocí klávesnice k ovládacím prvkům ve formuláři.