如何在运行时检查使用VB的DataGridViewCheckBoxColumn创建的复选框 [英] How to check a checkbox created with VB's DataGridViewCheckBoxColumn on Runtime
本文介绍了如何在运行时检查使用VB的DataGridViewCheckBoxColumn创建的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在运行时检查/勾选使用DataGridViewCheckBoxColumn创建的列。
I wanted to check/tick a column created with DataGridViewCheckBoxColumn on runtime.
这是我的代码段;
Dim checkCol As DataGridViewCheckBoxColumn = New DataGridViewCheckBoxColumn()
DataGridView1.Columns.Add(checkCol)
添加此列后,我想在启动VB应用程序时选中/选中其中某些复选框。
After I added this column, I wanted to check/tick some of these checkboxes on start up of the VB application.
我该怎么做?我是否必须使用Checkbox Class中的某些方法?
谢谢
How do I do that? Do I have to make use of some of the methods from Checkbox Class? thanks
推荐答案
A CheckBox
接受两个值: True
(选中)或 False
(未选中)。您可以在运行时通过以下操作设置/获取 DataGridView
的任何单元格的值:
A CheckBox
accepts two values: True
(checked) or False
(unchecked). You can set/get the values of any cell of you DataGridView
at runtime by doing:
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.
这篇关于如何在运行时检查使用VB的DataGridViewCheckBoxColumn创建的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文