Label.UseMnemonic 속성

정의

컨트롤이 컨트롤의 속성에 Text 있는 앰퍼샌드 문자(&)를 액세스 키 접두사 문자로 해석하는지 여부를 나타내는 값을 가져오거나 설정합니다.

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

속성 값

레이블에 앰퍼샌드 문자가 표시되지 않고 표시된 텍스트 내에서 앰퍼샌드 다음에 오는 문자에 밑줄을 그어지며 밑줄이 그어진 문자가 선택키로 처리되면 true이고 앰퍼샌드 문자가 컨트롤의 텍스트에 표시되면 false입니다. 기본값은 true입니다.

예제

다음 코드 예제를 만드는 Label 방법에 설명 합니다 3 차원 테두리와 이미지를 사용 하 여 ImageList 표시 되는 컨트롤을 및 ImageIndex 속성입니다. 또한 컨트롤에는 니모닉 문자가 지정된 캡션 있습니다. 예제 코드는 및 PreferredWidth 속성을 사용하여 PreferredHeight 컨트롤이 표시되는 폼의 Label 컨트롤 크기를 적절하게 조정합니다. 이 예제에서는 ImageList 을 만들고 imageList1로 명명하고 두 개의 이미지를 로드해야 합니다. 또한 이 예제에서는 코드가 해당 코드에 네임스페이스가 추가된 System.Drawing 양식 내에 있어야 합니다.

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

설명

속성이 UseMnemonictrue 설정되고 니모닉 문자(앰퍼샌드 앞에 오는 문자)가 의 Label속성에 Text 정의된 경우 ALT+를 누르면 니모닉 문자가 탭 순서에서 뒤에 오는 Label 컨트롤로 포커스를 설정합니다. 이 속성을 사용하여 양식의 컨트롤에 적절한 키보드 탐색을 제공할 수 있습니다.

적용 대상

추가 정보