C # DataGridView checkbox regardless of row selection

thanks for the help ... I have a datagridview (C # Winforms) with a checkbox column. When any of them click, it automatically selects the row. (Although it is not). How do I deselect a row from a checkbox embossing? In other words, I want to enable multiple row selection without executing the corresponding checkboxes, and also click multiple checkboxes without "auto-selecting" the rows where the checkboxes are "checked"? ~ Ron

+2


source to share


1 answer


I'm not sure if this is what you are looking for, but hopefully it points you in the right direction. If you want to ensure that no rows are selected when you edit the cell value, you can handle the CellBeginEdit DataGridView event.

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 keep the existing selection, you will need to implement a more complex handler, for example, save the indices of the selected rows and restore them after.

+1


source







All Articles