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 элемент управления с трехмерной границей и изображением, отображаемым с помощью ImageList и ImageIndex свойства. Элемент управления также содержит заголовок с заданным символом mnemonic. В примере кода используются PreferredHeight свойства и PreferredWidth свойства для правильного 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
Комментарии
UseMnemonic Если для свойства задано true значение, а в свойстве Labelамперсанда определяется Text символ mnemonic (символ, предшествующий амперсанду), нажатие клавиш ALT+ mnemonic символ задает фокус на элемент управления, который следует Label за порядком табуляции. Это свойство можно использовать для обеспечения правильной навигации по клавиатуре элементам управления в форме.