lundi 2 mars 2015

How to make Enter on a CheckBox and MVPDatePicker act as TAB button

I want the Enter Key to behave as the TAB key. Therefore I've been using the keyDown event with the following code:



if (e.KeyCode == Keys.Enter)
{
e.SuppressKeyPress = true;
SelectNextControl(ActiveControl, true, true, true, true);
}


or



if (e.KeyCode == Keys.Enter)
{
SendKeys.Send("{TAB}");
}


However, whenever I encounter a CheckBox or a MVPDatePicker control, the focus got lost and pressing enter doesn't do anything anymore. I had to press TAB to unlock the situation.


Does anyone have an idea on how to solve this problem?


Aucun commentaire:

Enregistrer un commentaire