windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-dot-assignshortcutkeytocommand-x28-keys-keys-richeditcommandid-boolean-x29.md
Assigns a shortcut key to a command. The shortcut key is available for all RichEdit views.
Namespace : DevExpress.XtraRichEdit
Assembly : DevExpress.XtraRichEdit.v25.2.dll
NuGet Package : DevExpress.Win.RichEdit
public void AssignShortcutKeyToCommand(
Keys key,
Keys modifier,
RichEditCommandId commandId,
bool updateToolTip
)
Public Sub AssignShortcutKeyToCommand(
key As Keys,
modifier As Keys,
commandId As RichEditCommandId,
updateToolTip As Boolean
)
| Name | Type | Description |
|---|---|---|
| key | Keys |
A Keys enumeration member specifying a key to assign.
| | modifier | Keys |
A Keys enumeration member specifying a modifier key.
| | commandId | RichEditCommandId |
A RichEditCommandId enumeration member specifying a command.
| | updateToolTip | Boolean |
True to modify a tooltip of the BarItem to which a command is assigned; otherwise, false.
|
The AssignShortcutKeyToCommand method override enables you to modify a tooltip of the bar item (the BarItem.SuperTip property) in the RichEdit UI so that it displays the correct shortcut information. To do this, set the updateToolTip parameter to true.
Note
If the command already has a shortcut, the AssignShortcutKeyToCommand method does not change the related tooltip. The tooltip will show the previously assigned shortcut.
To remove a command shortcut, use the RichEditControl.RemoveShortcutKey method.
The following code assigns Ctrl+G shortcut to ToggleShowWhitespaceCommand and removes predefined Ctrl+N shortcut so that it is no longer in use.
using System.Windows.Forms;
richEditControl.Text = "Use 'Ctrl+G' shortcut to show/hide whitespace characters";
richEditControl.Text += "\r\nYou can no longer use the 'Ctrl+N' shortcut to create a new document.";
richEditControl.AssignShortcutKeyToCommand(Keys.Control, Keys.G, RichEditCommandId.ToggleShowWhitespace);
richEditControl.RemoveShortcutKey(Keys.Control, Keys.N);
Imports System.Windows.Forms
richEditControl.Text = "Use 'Ctrl+G' shortcut to show/hide whitespace characters"
richEditControl.Text += Constants.vbCrLf & "You can no longer use the 'Ctrl+N' shortcut to create a new document"
richEditControl.AssignShortcutKeyToCommand(Keys.Control, Keys.G, RichEditCommandId.ToggleShowWhitespace)
richEditControl.RemoveShortcutKey(Keys.Control, Keys.N)
See Also