We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I use the KeysBindingDialog to bind a keystroke combination to any standard or custom command?

Platform: WinForms |
Control: EditControl |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

This samples helps you to know, how to bind a keystroke combination to any command.

Please refer to the code snippets below and the sample attached to know how to bind a keystroke combination to any command.

C#

private void menuItem1_Click(object sender, System.EventArgs e)

{

this.editControl1.BindKeyboard();

}

//Event that is raised when class registers commands for KeyBinding

this.editControl1.RegisteringKeyCommands += new System.EventHandler(this.editControl1_RegisteringKeyCommands);

//Event that is raised when class registers default KeyBinding

this.editControl1.RegisteringDefaultKeyBindings += new

System.EventHandler(this.editControl1_RegisteringDefaultKeyBindings);

// Bind the action name to the action using the RegisteringKeyCommands and ProcessCommandEventHandler events

private void editControl1_RegisteringKeyCommands(object sender, System.EventArgs e)

{

this.editControl1.Commands.Add( "File.SaveCommand" ).ProcessCommand +=

new ProcessCommandEventHandler( Command_Save );

}

// Bind key combinations to the action name using the RegisteringDefaultKeyBindings event

private void editControl1_RegisteringDefaultKeyBindings(object sender, System.EventArgs e)

{

this.editControl1.KeyBinder.BindToCommand( Keys.Control | Keys.S, "File.SaveCommand" );

}

// Define the action that needs to be performed

private void Command_Save()

{

this.editControl1.Save();

}

VB

Private Sub menuItem1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem1.Click

editControl1.BindKeyboard()

End Sub

Private Sub editControl1_RegisteringKeyCommands(ByVal sender As Object, ByVal e As System.EventArgs)

Handles editControl1.RegisteringKeyCommands

AddHandler editControl1.Commands.Add("File.SaveCommand").ProcessCommand, AddressOf Command_Save

End sub

Private Sub Command_Save()

editControl1.Save()

End Sub

Private Sub editControl1_RegisteringDefaultKeyBindings(ByVal sender As Object, ByVal e As System.EventArgs)

Handles editControl1.RegisteringDefaultKeyBindings

Me.editControl1.KeyBinder.BindToCommand(Keys.Control Or Keys.S, "File.SaveCommand")

End sub

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon