Prevent datagrid cell from receiving focus

  • Thread starter Thread starter Mervin Williams
  • Start date Start date
M

Mervin Williams

I have two columns in a datagrid - the first holds the "name" and the second
holds the "value". Only the "value column should ever receive focus. How
do I prevent focus from ever going to the first column?

Thanks in advance,

Mervin Williams
 
Mervin said:
I have two columns in a datagrid - the first holds the "name" and the second
holds the "value". Only the "value column should ever receive focus. How
do I prevent focus from ever going to the first column?

Thanks in advance,

Mervin Williams

You could use the CellContentClick event of the datagrid.
Then in the handler you check which datacolumn is clicked for example:

private void dataGridView1_CellContentClick(object sender,
DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0)
{
// put focus somewhere else.
}
}

I hope this helps. Maybe there are other solutions.

Have fun.

Eric
MCP (C#)
 
Back
Top