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#)
 

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

Similar Threads

Change focus 3
focus on otherform.textbox from datagrid 1
custom control focus 1
Problems with DataGrid 2
Focus problem 1
DataGrid ReadOnly Column BUG ! 3
PropertyGrid steals focus 3
Form activated 4

Back
Top