Someone could help me, I wanted to create a command with the keys CTRL
+ Z
or something like that to save, edit or send data as a shortcut to a button created in Form
.
Someone could help me, I wanted to create a command with the keys CTRL
+ Z
or something like that to save, edit or send data as a shortcut to a button created in Form
.
Change the KeyPreview
of form as true
.
Set the actions for the shortcuts in the #
Example:
private void MainForm_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.Z)
Desfazer();
if (e.Control && e.KeyCode == Keys.S)
Salvar();
//Assim por diante
}
You can also override the KeyDown
method.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.S))
{
Salvar();
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}