proxyuser
2009-09-10 21:38:08 UTC
I want the enter key to work like the tab key, and the tab key to just skip
out of the control.
The latter is easily solved by changing the StandardTab property to True.
Then I derived a class from DataGridView and overrode the ProcessDialogKey
and ProcessDataGridViewKey methods. Then I handle the Enter key behavior.
But of course I can't just tell it to behave like the Tab key, because now
the Tab key works differently because of the StandardTab setting. I tried
this, but it doesn't work. Any other ideas?
protected override bool ProcessDialogKey( Keys keyData )
{
if ( keyData == Keys.Enter )
{
StandardTab = false;
bool retCode = base.ProcessTabKey(Keys.Tab);
StandardTab = true;
return retCode;
}
return base.ProcessDialogKey(keyData);
}
out of the control.
The latter is easily solved by changing the StandardTab property to True.
Then I derived a class from DataGridView and overrode the ProcessDialogKey
and ProcessDataGridViewKey methods. Then I handle the Enter key behavior.
But of course I can't just tell it to behave like the Tab key, because now
the Tab key works differently because of the StandardTab setting. I tried
this, but it doesn't work. Any other ideas?
protected override bool ProcessDialogKey( Keys keyData )
{
if ( keyData == Keys.Enter )
{
StandardTab = false;
bool retCode = base.ProcessTabKey(Keys.Tab);
StandardTab = true;
return retCode;
}
return base.ProcessDialogKey(keyData);
}