Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,
I have a mdi main form in which there are some menus. i made a form which i was not show in that menus. i just want to open that form by click and key from keyboard like alt+F6, Ctrl+F6 like something...
so i want to know the code for open that form by click any key. i have already written a 2 line code in keypress event of my main form.
that is....
C#
if (e.KeyChar == 63) // Ctrl + F6
{
  Cotation ct = new Cotation();
  ct.MdiParent = this;
  ct.Show();
}

but it was not working...
what was i doing wrong? Help me for this...
Thanks in advance...
Posted
Updated 6-Feb-13 21:10pm
v2

1 solution

Instead of using KeyDown, use KeyUp. It shall work. I have tried it out. The following code snippet should do it.

C#
private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyData.ToString().Equals("F6, Control"))
            {
                Cotation ct = new Cotation();
                ct.MdiParent = this;
                ct.Show();
            }
        }


Hope this helps.
 
Share this answer
 
v2
Comments
tanisha pandey 7-Feb-13 3:50am    
I tried this but it was stop at the last line of below code.

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Login());

this is i wrote in Program.cs to open my log in page.
i can't understand the problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900