windowsforms-devexpress-dot-utils-dot-textoptions-25eb4076.md
Gets or sets whether to underline characters that are preceded with an ampersand symbol (&). This option is supported by a set of controls.
Namespace : DevExpress.Utils
Assembly : DevExpress.Utils.v25.2.dll
NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core
[DefaultValue(HKeyPrefix.Default)]
[XtraSerializableProperty]
public virtual HKeyPrefix HotkeyPrefix { get; set; }
<DefaultValue(HKeyPrefix.Default)>
<XtraSerializableProperty>
Public Overridable Property HotkeyPrefix As HKeyPrefix
| Type | Default | Description |
|---|---|---|
| HKeyPrefix | Default |
A value that specifies how to interpret an ampersand character (&) in text.
|
Available values:
| Name | Description |
|---|---|
| Default |
Underline the character that is preceded by the ampersand symbol (&) when a user presses ALT.
| | None |
Show the ampersand symbol (&).
| | Show |
Underline the character preceded by the ampersand symbol (&).
| | Hide |
Do not underline the character that is preceded by the ampersand symbol (&).
|
You can access this nested property as listed below:
| Object Type | Path to HotkeyPrefix |
|---|---|
| AppearanceObject |
.TextOptions .HotkeyPrefix
| | TextOptions |
.DefaultOptions .HotkeyPrefix
| | TextOptions |
.DefaultOptionsCenteredWithEllipsis .HotkeyPrefix
| | TextOptions |
.DefaultOptionsMultiLine .HotkeyPrefix
| | TextOptions |
.DefaultOptionsNoWrap .HotkeyPrefix
| | TextOptions |
.DefaultOptionsNoWrapEx .HotkeyPrefix
|
For a set of controls, you can precede a specific character in the control’s text with an ampersand symbol (&) to create a shortcut (hotkey). All controls that support this feature underline target characters when a user presses the ALT key (the default behavior). The ALT+Character shortcut activates control functionality.
The following example demonstrates a sample button whose text is set to “&Run”. The ‘ALT+R’ shortcut will activate button action.
simpleButton1.Text = "&Run";
SimpleButton1.Text = "&Run"
The following controls support the use of the ampersand symbol (&) to create hotkeys.
Bar items in standard bars (BarManager)
Buttons (SimpleButton and descendants)
Labels (LabelControl and descendants)
RadioGroup control items
The HotkeyPrefix property allows you to choose one of display modes for characters preceded by an ampersand symbol (&):
The HotkeyPrefix property does not allow you to disable the hotkey functionality.
To disable the hotkey functionality and display the ampersand symbol as is, double the ampersand character in the control’s text.
simpleButton1.Text = "Fix&&Go";
SimpleButton1.Text = "Fix&&Go"
When an AppearanceObject’s style setting (for example, BackColor , ForeColor , Font and TextOptions.HAlignment ) is set to a non-default value, the corresponding Options.Use… option (for instance, Options.UseBackColor , Options.UseForeColor , Options.UseFont and Options.UseTextOptions ) is automatically set to true in the following cases:
In other cases, the Options.Use… options are not automatically enabled. You may need to enable these options manually for the style settings to be in effect.
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the HotkeyPrefix property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
AppearanceObject a = pInfo.PaintAppearance;
System.Drawing.Text.HotkeyPrefix? hotKeyPrefixOverride = (a.TextOptions.HotkeyPrefix == HKeyPrefix.Default) || pInfo.UseHotkeyPrefixDrawModeOverride ?
new System.Drawing.Text.HotkeyPrefix?(pInfo.HotkeyPrefixDrawModeOverride) : null;
See Also