المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Providing Shortcut key for winform - (Ctrl+S)



C# Programming
08-25-2009, 12:03 PM
Hi All,

I'm working on a project where on the left hand side of the form i have a treeview control and bottom to that i have some buttons. When user clicks on the node then i'm loading respective user control on to the right hand side of the form.

The issue here is i have two save buttons one on user control and other on the main form just below the treeview control. I have the code to capture the key press :

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.S))
{
MessageBox.Show("Do Something");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}

Here this code works only for the main form but not for the user control.

Please let me know how can i capture the key press event for usercontrol so that i can call save event of usercontrol.

Thanks in Advance
Regards,
Prakash N