0
Someone could help me, wanted to create a command with the keys CTRL
+ Z
or something to save, edit or send data, as a shortcut to a button created on Form
.
0
Someone could help me, wanted to create a command with the keys CTRL
+ Z
or something to save, edit or send data, as a shortcut to a button created on Form
.
2
Change the property KeyPreview
of form as true
.
Set actions for shortcuts in the event KeyDown
of form
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
}
It is also possible to override the method ProcessCmdKey
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.S))
{
Salvar();
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
Thanks for your attention I’ll test here.
Browser other questions tagged c# winforms
You are not signed in. Login or sign up in order to post.
Windows Forms??
– Jéf Bueno
Yes, Visual Studio.
– Wesley Alves
Does the answer meet the request? Does it need something to be improved?
– Jéf Bueno