Hi, Please tell me how can i bind keyboard shortcut keys with any button code in windows form application. Give me an example
Thanks in advance
Regards Zeb-ur-Rehman
Loading
Zeb RehmanPosted Jan 7, 2011, 9:09 AM
ShankeyPosted Jan 7, 2011, 8:33 AM
you want to call startToolStripMenuItem_Click
then just write following line in your if block:
startToolStripMenuItem_Click(sender, e);
hope it will work.....:)
Zeb RehmanPosted Jan 7, 2011, 8:00 AM
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.X && e.Modifiers == Keys.Alt)
{
here i want to execute startToolStripMenuItem_Click which is given under
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
private void startToolStripMenuItem_Click(object sender, EventArgs e)
{
timer1.Interval = 1000;
timer1.Start();
startToolStripMenuItem.Enabled = false;
stopToolStripMenuItem.Enabled = true;
}
ShankeyPosted Jan 7, 2011, 7:48 AM
if you include an '&' in the buttons text property, the following letter will become an accelerator and respond to Alt+Key combinations.
eg; if you create a button with the text property set to "&Binded", the buttons text will appear as "Binded" and if you press Alt + B it will perform a button click.