Pages

Friday, 19 August 2011

How to use Shortcut Key in C Sharp (C#) Program

I am created 2 forms using c# (Form A and Form B). From Form A i want to open Form B when I press a Key (F2).

Steps
1. Set Form A KeyPreview Property to True.
2. Write needed code in Form A KeyDown Event.

private void A_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F2)
{
new B().Show();
}
}

Done...Check it out.

0 comments:

Post a Comment