Prevent datagrid cell from receiving focus

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
 
E

Eric via DotNetMonster.com

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

Top