How to open new form when Enter as Tab?

49 views Asked by At

When I Press Enter button, it acts as Tab with this code at form1_keydown event

 Control nextControl; 
 if (e.KeyCode == Keys.Enter)
 {
 nextControl = GetNextControl(ActiveControl, !e.Shift);
 nextControl.Focus();
 e.SuppressKeyPress = true;
 }

There is comboBoxin a form to which we press Enter button then open New Form.
How to do it because it doesn't work on cmb_KeyPressevent

1

There are 1 answers

0
Vampire On BEST ANSWER

Here You can wirte as:

 Control nextControl; 
 if (e.KeyCode == Keys.Enter)
 {
nextControl = GetNextControl(ActiveControl, !e.Shift);
nextControl.Focus();
if(nextControl=Combo)
{
KeyPreview=false;   
}
e.SuppressKeyPress = true;
}