StringFormat.HotkeyPrefix Właściwość
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Pobiera lub ustawia HotkeyPrefix obiekt dla tego StringFormat obiektu.
public:
property System::Drawing::Text::HotkeyPrefix HotkeyPrefix { System::Drawing::Text::HotkeyPrefix get(); void set(System::Drawing::Text::HotkeyPrefix value); };
public System.Drawing.Text.HotkeyPrefix HotkeyPrefix { get; set; }
member this.HotkeyPrefix : System.Drawing.Text.HotkeyPrefix with get, set
Public Property HotkeyPrefix As HotkeyPrefix
Wartość właściwości
Obiekt dla tego StringFormat obiektu, wartość domyślna HotkeyPrefix to None.
Przykłady
W poniższym przykładzie kodu pokazano, jak ustawić skrót klawiaturowy przy użyciu HotkeyPrefix właściwości . Pokazuje również, jak używać FromSystemColor metody . Aby uruchomić ten przykład, wklej kod do formularza, obsłuż zdarzenie formularza Paint i wywołaj następującą metodę, przekazując wartość e jako PaintEventArgs.
private:
void ShowHotKey( PaintEventArgs^ e )
{
// Declare the string with a keyboard shortcut.
String^ text = "&Click Here";
// Declare a new StringFormat.
StringFormat^ format = gcnew StringFormat;
// Set the HotkeyPrefix property.
format->HotkeyPrefix = System::Drawing::Text::HotkeyPrefix::Show;
// Draw the string.
Brush^ theBrush = SystemBrushes::FromSystemColor( SystemColors::Highlight );
e->Graphics->DrawString( text, this->Font, theBrush, 30, 40, format );
}
private void ShowHotKey(PaintEventArgs e)
{
// Declare the string with a keyboard shortcut.
string text = "&Click Here";
// Declare a new StringFormat.
StringFormat format = new StringFormat();
// Set the HotkeyPrefix property.
format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
// Draw the string.
Brush theBrush =
SystemBrushes.FromSystemColor(SystemColors.Highlight);
e.Graphics.DrawString(text, this.Font, theBrush, 30, 40, format);
}
Private Sub ShowHotKey(ByVal e As PaintEventArgs)
' Declare the string with keyboard shortcut.
Dim text As String = "&Click Here"
' Declare a new StringFormat.
Dim format As New StringFormat
' Set the HotkeyPrefix property.
format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show
' Draw the string.
Dim theBrush As Brush = _
SystemBrushes.FromSystemColor(SystemColors.Highlight)
e.Graphics.DrawString(text, Me.Font, theBrush, 30, 40, format)
End Sub
Uwagi
W graficznym interfejsie użytkownika klawisz hot key jest podkreśloną literą w słowie (zwykle połączonym z innym klawiszem, takim jak klawisz Alt), który można nacisnąć na klawiaturze, aby aktywować funkcjonalność, którą reprezentuje wyraz.
Dotyczy
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla