DataGridViewCheckBoxCell单元格点击后立即更改选中状态

 

 Private Sub DataGridView1_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseClick
        If DataGridView1(e.ColumnIndex, e.RowIndex).GetType = GetType(WinForms.DataGridViewCheckBoxCell) Then
            Dim chkCell As WinForms.DataGridViewCheckBoxCell = DirectCast(DataGridView1(e.ColumnIndex, e.RowIndex), WinForms.DataGridViewCheckBoxCell)
            chkCell.Value = Not chkCell.Value
            DataGridView1.EndEdit()
        End If
 End Sub

 

posted @ 2023-06-12 22:42  rf8862  阅读(75)  评论(0编辑  收藏  举报