如何在运行时检查使用VB的DataGridViewCheckBoxColumn创建的复选框

时间:2013-09-02 10:18:49

标签: vb.net visual-studio visual-studio-2008 datagridview

我想检查/勾选在运行时使用DataGridViewCheckBoxColumn创建的列。

这是我的代码片段;

Dim checkCol As DataGridViewCheckBoxColumn = New DataGridViewCheckBoxColumn()
DataGridView1.Columns.Add(checkCol)

在我添加此列之后,我想在启动VB应用程序时检查/勾选其中一些复选框。

我该怎么做?我是否必须使用Checkbox Class中的一些方法? 感谢

1 个答案:

答案 0 :(得分:1)

CheckBox接受两个值:True(已选中)或False(未选中)。您可以通过执行以下操作在运行时设置/获取您DataGridView的任何单元格的值:

DataGridView1(0, 0).Value = True 'Checking the CheckBox in the first row/first column 
Dim isChecked As Boolean = DirectCast(DataGridView1(0, 2).Value, Boolean) 'Getting the check status of the third row/first column.
相关问题