Click here to Skip to main content
15,913,408 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
how to use shortcut keys in a form? i have 1 form after loading the form click the F3 button to display the gridview. is it possible
Posted

Set the KeyPreview property for the form to true, and override the ProcessCmdKey() method.

protected override bool ProcessCmdKey(ref Message msg, Keys keyData) 
{ 
    if (keyData == (Keys.Control | Keys.A)) 
    { 
        // do asomething 
        return true; 
    } 
    return base.ProcessCmdKey(ref msg, keyData); 
} 
 
Share this answer
 
v2
If you set the KeyPreview property on you main form to true, then you should be able to catch any keypresses for the form in the key KeyDown event. You should check for any keys you want there.
 
Share this answer
 

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