In my WinForms I have DataGridView
. I wanted to select full row at once so I set SelectionMode
as FullRowSelect
. And now I have problem, because at the beginning my form underlines first row (set of selected rows is empty, the first row is not selected but just underlined). I have tried many things, such as:
private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
dataGridView1.ClearSelection();
}
And all failed, because in fact there is no selection.
How can I get rid of this underline?
Thanks for any help!
Just put dataGridView1.ClearSelection();
in load event of the form.
This works for me:
private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
dataGridView1.Rows[0].Selected = false;
}
Unfortunately none of these answers helped me, but I found other solution. Instead of unable selection I will just hide it with this piece of code:
dataGridView1.DefaultCellStyle.SelectionBackColor = dataGridView1.DefaultCellStyle.BackColor;
dataGridView1.DefaultCellStyle.SelectionForeColor = dataGridView1.DefaultCellStyle.ForeColor;
So if anyone just wants to hide the selection it's gonna work pretty well.
Cheers :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With