Reputation: 6061
I have a datagridview that may or may not have rows selected when the user sorts it by clicking on a column header. If there are rows selected there isn't a problem, but if there are 0 selected rows then the sort selects a row automatically (the selection is consistant but I'm not wure what the criteria is). How can I prevent this behavior from happening.
If it's relevant, the DGV is not databound and has full row select enabled.
Upvotes: 2
Views: 3293
Reputation: 2746
Handle the Sorted event of the DataGridView:
this.dataGridView1.Sorted += new System.EventHandler(dataGridView1_Sorted);
void dataGridView1_Sorted(object sender, System.EventArgs e)
{
dataGridView1.ClearSelection();
}
Upvotes: 6