StringFormat::HotkeyPrefix Property
.NET Framework (current version)
Gets or sets the HotkeyPrefix object for this StringFormat object.
Assembly: System.Drawing (in System.Drawing.dll)
public: property HotkeyPrefix HotkeyPrefix { HotkeyPrefix get(); void set(HotkeyPrefix value); }
Property Value
Type: System.Drawing.Text::HotkeyPrefixThe HotkeyPrefix object for this StringFormat object, the default is None.
In a graphical user interface, a hot key is the underlined letter in a word (usually combined with another key, such as the Alt key) that you can press on the keyboard to activate the functionality that the word represents.
The following code example shows how to set a keyboard shortcut using the HotkeyPrefix property. It also demonstrates how to use the FromSystemColor method. To run this example, paste the code into a form, handle the form's Paint event and call the following method, passing e as 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 ); }
.NET Framework
Available since 1.1
Available since 1.1
Show: