set multiple checkboxes to true in datagridview
-
hi all i have a datagridview with three columns. the first column contains checkboxes, the two and three contains text. the selection mode is fullrowselect. my problem is that, when multiple columns are selected while keeping the shift key pressed and then space is pressed with shift key all the checkboxes are supposed to be selected. i tried the code
If flagShift = True And e.KeyCode = Keys.Space Then If DataGridView2.SelectedRows.Count > 1 Then For i As Integer = 0 To DataGridView2.Rows.Count - 1 If DataGridView2.Rows(i).Selected = True Then If DataGridView2.Rows(i).Cells(0).Value = True Then DataGridView2.Rows(i).Cells(0).Value = False Else DataGridView2.Rows(i).Cells(0).Value = True End If End If Next End If End If
but that will check all the checkboxes except the last one. the last one remains unchecked. thanks in advance. help everyone -
hi all i have a datagridview with three columns. the first column contains checkboxes, the two and three contains text. the selection mode is fullrowselect. my problem is that, when multiple columns are selected while keeping the shift key pressed and then space is pressed with shift key all the checkboxes are supposed to be selected. i tried the code
If flagShift = True And e.KeyCode = Keys.Space Then If DataGridView2.SelectedRows.Count > 1 Then For i As Integer = 0 To DataGridView2.Rows.Count - 1 If DataGridView2.Rows(i).Selected = True Then If DataGridView2.Rows(i).Cells(0).Value = True Then DataGridView2.Rows(i).Cells(0).Value = False Else DataGridView2.Rows(i).Cells(0).Value = True End If End If Next End If End If
but that will check all the checkboxes except the last one. the last one remains unchecked. thanks in advance. help everyoneYah, I hate this problem and I hope you get a better solution than mine. I created an additional checkbox below the gridview called checkselected. It has 2 operations: if there are no rows selected then it forces EVERY row to have its checked value. If there is 1 or more selected rows it forces the seleced rows to have the checkbox value.
Quote from Great Outdoors: its a confident traveller who farts in India