Label.UseMnemonic Property

Definition

컨트롤의 Text 속성에서 앰퍼샌드 문자(&)를 선택키 접두사로 해석할지를 나타내는 값을 가져오거나 설정합니다.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.

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

Property Value

Boolean

레이블에 앰퍼샌드 문자가 표시되지 않고 표시된 텍스트 내에서 앰퍼샌드 다음에 오는 문자에 밑줄을 그어지며 밑줄이 그어진 문자가 선택키로 처리되면 true이고 앰퍼샌드 문자가 컨트롤의 텍스트에 표시되면 false입니다.true if the label doesn't display the ampersand character and underlines the character after the ampersand in its displayed text and treats the underlined character as an access key; otherwise, false if the ampersand character is displayed in the text of the control. 기본값은 true입니다.The default is true.

Examples

다음 코드 예제에서는 ImageListImageIndex 속성을 사용 하 여 3 차원 테두리와 이미지를 표시 하는 Label 컨트롤을 만드는 방법을 보여 줍니다.The following code example demonstrates how to create a Label control that has a three-dimensional border and an image displayed using the ImageList and ImageIndex properties. 컨트롤에 지정 된 니모닉 문자를 사용 하 여는 캡션이 있습니다.The control also has a caption with a mnemonic character specified. 예제 코드는 PreferredHeightPreferredWidth 속성을 사용 하 여 표시 되는 폼에서 Label 컨트롤의 크기를 적절히 조정 합니다.The example code uses the PreferredHeight and PreferredWidth properties to properly size the Label control on the form on which it is displayed. 이 예에서는 ImageList을 만들고 이름을 imageList1로 지정 하 고 두 개의 이미지를 로드 해야 합니다.This example requires that an ImageList has been created and named imageList1 and that it has loaded two images. 또한이 예제에서는 코드에 System.Drawing 네임 스페이스를 추가 하는 폼 안에 코드가 있어야 합니다.The example also requires that the code is within a form that has the System.Drawing namespace added to its code.

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

Remarks

UseMnemonic 속성이 true로 설정 되 고 니모닉 문자 (앰퍼샌드 뒤에 오는 문자)가 LabelText 속성에 정의 되어 있는 경우 ALT + 니모닉 문자를 누르면 탭 순서에서 Label 다음에 오는 컨트롤에 포커스가 설정 됩니다.If the UseMnemonic property is set to true and a mnemonic character (a character preceded by the ampersand) is defined in the Text property of the Label, pressing ALT+ the mnemonic character sets the focus to the control that follows the Label in the tab order. 폼의 컨트롤에 적절 한 키보드 탐색을 제공 하려면이 속성을 사용할 수 있습니다.You can use this property to provide proper keyboard navigation to the controls on your form.

Applies to

See also