The controls you have added are getting the keystrokes before the form does,
and if they handle the keystroke, then the form will not see it.
You can try setting the form's KeyPreview property to "true". Or, if it's
command keys you want to handle, you may be better off overriding
ProcessCmdKey, something like this:
protected override bool ProcessCmdKey(ref Message msg,Keys keyData)
{
// If the "current gridview" property is assigned, then all
// Up/Down arrows should navigate the grid
if ( gvCurrent == null )
{
return base.ProcessCmdKey(ref msg, keyData);
}
if ( gvCurrent.GridControl.Enabled == false )
{
return base.ProcessCmdKey(ref msg, keyData);
}
switch (keyData)
{
case Keys.Up:
gvCurrent.MovePrev();
return true;
case Keys.Down:
gvCurrent.MoveNext();
return true;
case Keys.PageUp:
gvCurrent.MovePrevPage();
return true;
case Keys.PageDown:
gvCurrent.MoveNextPage();
return true;
default:
return base.ProcessCmdKey(ref msg, keyData);
}
}
"vidalsasoon" <kj*****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I looked a little deeper into my problem and saw that as soon as I add
any control to my form, my "protected override void OnKeyDown" method
stops getting picked up. any reason why this happens?