Back to Devexpress

RichEditControl.AssignShortcutKeyToCommand(Keys, Keys, RichEditCommandId, RichEditViewType) Method

windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-dot-assignshortcutkeytocommand-x28-keys-keys-richeditcommandid-richeditviewtype-x29.md

latest4.0 KB
Original Source

RichEditControl.AssignShortcutKeyToCommand(Keys, Keys, RichEditCommandId, RichEditViewType) Method

Assigns a shortcut key to a command. The shortcut key is available for the specified RichEditView.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.XtraRichEdit.v25.2.dll

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
public void AssignShortcutKeyToCommand(
    Keys key,
    Keys modifier,
    RichEditCommandId commandId,
    RichEditViewType viewType
)
vb
Public Sub AssignShortcutKeyToCommand(
    key As Keys,
    modifier As Keys,
    commandId As RichEditCommandId,
    viewType As RichEditViewType
)

Parameters

NameTypeDescription
keyKeys

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.

| | viewType | RichEditViewType |

A RichEditView specifying the view in which a shortcut will be effective

|

Remarks

To remove a command shortcut, use the RichEditControl.RemoveShortcutKey method.

Example

The following code assigns Ctrl+G shortcut to ToggleShowWhitespaceCommand and removes predefined Ctrl+N shortcut so that it is no longer in use.

View Example

csharp
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);
vb
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

RemoveShortcutKey

RichEditControl Class

RichEditControl Members

DevExpress.XtraRichEdit Namespace