2
votes

thx in advance for the help... I have a datagridview (c# Winforms) with a column of checkboxes. When any of these are clicked, it automatically selects the row. (Although not th eother way around). How do I de-couple row selection from the checcking of the checkbox ? In other words, I want to enable multiple row selection, without effecting the corresponding checkboxes, and also click multiple checkboxes without "automatically selecting" the rows where the checkboxes are "checked" ? ~Ron

1

1 Answers

1
votes

I am not certain if this is what you are looking for, but hopefully it will point you in the right direction. If you want to make certain that no rows are selected when you edit the value of a cell you can handle the CellBeginEdit event of the DataGridView.

this.dataGridView1.CellBeginEdit += new System.Windows.Forms.DataGridViewCellCancelEventHandler(dataGridView1_CellBeginEdit);

void dataGridView1_CellBeginEdit(object sender, System.Windows.Forms.DataGridViewCellCancelEventArgs e)
{
 dataGridView1.ClearSelection();
}

If you want to maintain the existing selection you will need to implement a more complex handler, such as saving the indexes of the currently selected rows and restoring them after.