1
votes

How can I remove the current cell focus from a Windows Forms datagridview ? I have a dialog with some datagridforms and initially I don't want to have a cell selection. Actually in every gridview the cell [1,1] is selected

I have already searched in some forums, but the provided solutions doesn't work. For example often it is recommended to set CurrentCell = null --> but this has no effect. Has anybody another solution, which really works ;-) ?

2

2 Answers

5
votes

I think this will work:

if (dataGridView.RowCount > 0 && dataGridView.ColumnCount >0)
{
   dataGridView.CurrentCell = this.dataGridView[0, 0];
   this.dataGridView.CurrentCell.Selected = false;
} 
5
votes
dataGridView.ClearSelection();
dataGridView.CurrentCell = null;