Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable default cell selection in datagridView

Tags:

c#

winforms

I have DataGridView to load some data programmatically. After inserting my data I am showing the DataGridView . Here by default the 1st row 0th column cell is selected. But I don't need that. I have tried to disable that option.

datagridviewname.currentcell=null   

But it will not work. Any body can help me to solve my problem.

like image 267
Sivaperuman Avatar asked Jun 20 '13 08:06

Sivaperuman


2 Answers

Set CurrentCell Selected property to False like:

   dataGridViewName.CurrentCell.Selected = false;
like image 112
Edper Avatar answered Oct 27 '22 01:10

Edper


On the DataGridView create an event for DataBindingComplete then add this method datagridview1.ClearSelection()

private void datagridview1_DataBindingComplete(object sender, EventArgs e)
{
    datagridview1.ClearSelection();
}
like image 44
reversebind Avatar answered Oct 27 '22 00:10

reversebind