Remove the Focus from the DataGrid Control

  • Thread starter Thread starter J.H..
  • Start date Start date
J

J.H..

With who way I can remove the focus from a DataGrid Control using the key
Tab in a WinForm in C# ? The key Tab transports the focus in the next column
of DataGrid and no in the next WinForm Control.
 
Hi John,

You may like to subclass your datagrid and override the
ProcessCmdKey() to trap the TAB key and set the focus
to the desired control.

class MyDataGrid : DataGrid
{

// ..
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if(msg.WParam.ToInt32() == (Int32)Keys.Tab)
{
myWinFormControl.Focus();
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}

Regards,
Aravind C
 
Back
Top