Hi, I am builing one tool using C#. Its an windows application. I have one text box on a form and I want to assign focus to that text box when user presses Ctrl+F or Ctrl+S. I dont know how to do this. Can anyone please tell me how to do this?
views:
297answers:
2
                +2 
                A: 
                
                
              
            One way is to override the ProcessCMDKey event.
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);
}
EDIT: Alternatively you can use the keydown event - How to capture shortcut keys in Visual Studio .NET
                  Aseem Gautam
                   2010-03-23 10:35:15
                
              
                
                A: 
                
                
              
            Add an event that catches a key press on the form, analyse the key press and see if it matches one of your shortcut keys and then assign focus.
                  CeejeeB
                   2010-03-23 10:36:25