Click here to Skip to main content
16,016,306 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I've updated my code however, it will not clear the entire row when the checkbox is unchecked

VB
Private Sub dgvRecords_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick

        If e.ColumnIndex = 1 Then
            Dim IsChecked As Boolean = False
            IsChecked = CBool(DirectCast(DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells("No Records"), DataGridViewCheckBoxCell).EditedFormattedValue)
            If IsChecked Then
                If MessageBoxButtons.YesNo Then
                    If MsgBox("Did this person attend?", MsgBoxStyle.YesNo, "Attendance") = MsgBoxResult.Yes Then
                        DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells("Att. (Y/N)").Value = "Y"
                    Else
                        DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells("Att. (Y/N)").Value = "N"
                    End If
                Else
                    DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells.Clear()
                  
                End If
            End If
        End If
Posted

1 solution

Your code doesn't clear the cells when it's unchecked...it's clearing them when MessageBoxButtons.YesNo is False...which makes no sense. What were you trying to check for at that point? MessageBoxButtons.YesNo is an enumeration. It's always going to return the same value. I think you just want to take that If statement out, and leave the Else part to execute when the IsChecked is false.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900