TextOptions.HotkeyPrefix Property
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.v24.2.dll
Declaration
[DefaultValue(HKeyPrefix.Default)]
[XtraSerializableProperty]
public virtual HKeyPrefix HotkeyPrefix { get; set; }
Property Value
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 (&). |
Property Paths
You can access this nested property as listed below:
Object Type | Path to HotkeyPrefix |
---|---|
AppearanceObject |
|
TextOptions |
|
TextOptions |
|
TextOptions |
|
TextOptions |
|
TextOptions |
|
Remarks
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.
The following controls support the use of the ampersand symbol (&) to create hotkeys.
Bar items in standard bars (BarManager)
A hotkey invokes item action (for instance, the BarItem.ItemClick event).
Buttons (SimpleButton and descendants)
A hotkey invokes button action (the Click event).
-
A hotkey toggles the control’s check state.
Labels (LabelControl and descendants)
A hotkey moves focus to the next control in the tab order.
RadioGroup control items
A hotkey selects the item associated with the pressed hotkey.
The HotkeyPrefix property allows you to choose one of display modes for characters preceded by an ampersand symbol (&):
- Underline the next character when the ALT key is pressed.
- Always underline the next character.
- Do not underline the character.
- Show the 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.
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:
- The AppearanceObject belongs to a control/component (or its element), and this control/component has been completely loaded (see the control’s IsLoading property to check the load status);
- The AppearanceObject belongs to a grid column/band or tree list column/band, and the column/band belongs to a grid/tree list control;
- The AppearanceObject is standalone, that is, it does not belong to any control or component.
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.
Related GitHub Examples
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.