how to write the code to create short cut keys for buttons in c#.net
how to write the code to create short cut keys for buttons in c#.net
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
FroglegPosted Sep 14, 2012, 7:37 AM
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("I'm button 1");
}
private void button2_Click(object sender, EventArgs e)
{
bttnTwo();
}
public void bttnTwo()
{
MessageBox.Show("I'm button 2");
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode==Keys.A)//2 differnt ways
{
button1.PerformClick();
}
else if (e.KeyCode == Keys.B)
{
bttnTwo();
}
}
}
set form keypreview to true