Nyelv

Label.UseMnemonic Tulajdonság

Definíció

Lekéri vagy beállítja azt az értéket, amely jelzi, hogy a vezérlő a vezérlő Text tulajdonságában lévő ampers és karaktert (> egy hozzáférési kulcs előtagjának) értelmezi-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

Tulajdonság értéke

true ha a címke nem jeleníti meg az erősítőt és a karaktert, és aláhúzza a karaktert az erősítő és a megjelenített szöveg után, és az aláhúzott karaktert hozzáférési kulcsként kezeli; ellenkező esetben, false ha az erősítő és a karakter megjelenik a vezérlőelem szövegében. Az alapértelmezett érték a true.

Példák

Az alábbi példakód bemutatja, hogyan hozhat létre Label háromdimenziós szegélyt és a tulajdonságokat használó ImageListImageIndex képet tartalmazó vezérlőt. A vezérlőelem felirattal is rendelkezik, amelyen meg van adva egy mnemonikus karakter. A példakód a PreferredHeight vezérlő megfelelő méretének PreferredWidth és Label tulajdonságainak használatával méretezhető azon az űrlapon, amelyen megjelenik. Ehhez a példához létre kell hozni és el kell nevezni egy ImageList imageList1 nevű fájlt, és két képet kell betöltenie. A példához az is szükséges, hogy a kód egy olyan űrlapon belül legyen, amelyben a névtér hozzá van adva a System.Drawing kódhoz.

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

Megjegyzések

Ha a UseMnemonic tulajdonság be van állítva true , és egy mnemonikus karakter (az ampersand előzménye) van definiálva az TextLabelalt+ billentyű lenyomásával, a mnemonikus karakter a tabulátorsorrendet követő Label vezérlőelemre állítja a fókuszt. Ezzel a tulajdonságpal megfelelő billentyűzet-navigációt biztosíthat az űrlap vezérlőinek.

A következőre érvényes:

Lásd még