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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top