如何选中或取消选中Datagridviewcheckbox列 [英] How to check or uncheck a Datagridviewcheckboxcolumn

查看:574
本文介绍了如何选中或取消选中Datagridviewcheckbox列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Private Sub dgvBrowse_CellContentClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvBrowse.CellContentClick
       If CBool(dgvBrowse.Rows(e.RowIndex).Cells("Column1").Value) Then


           MessageBox.Show("The Value is Checked", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information)
           forchk()
       Else

           MessageBox.Show("UnChecked", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information)
       End If
   End Sub

推荐答案

您好。



试试这个:



Private Sub dgvBrowse_CellContentClick(ByVal sender As Object,ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)处理dgvBrowse。 CellContentClick



'检查列中的列是否为checkboxcolumn

如果dgvBrowse.Columns(e.ColumnIndex).Name =Column1则

'检查是否已检查

如果dgvBrowse.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = True然后

'显示索引

MsgBox(RowIndex:&e.RowIndex.ToString())

结束如果



结束如果



End Sub
Hi.

Try this:

Private Sub dgvBrowse_CellContentClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvBrowse.CellContentClick

'Check if column clicked was the checkboxcolumn
If dgvBrowse.Columns(e.ColumnIndex).Name = "Column1" Then
'Check if it is checked
If dgvBrowse.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = True Then
'Display index
MsgBox("RowIndex: " & e.RowIndex.ToString())
End If

End If

End Sub


这篇关于如何选中或取消选中Datagridviewcheckbox列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆