Datagridviewcheckbox列的检查值 [英] Datagridviewcheckbox column checked values
本文介绍了Datagridviewcheckbox列的检查值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在datagridview checkboxcolumn中,我应该只能获取检查后的值,因为这些是我应该存储在字符串数组中的值.我该怎么做?
In datagridview checkboxcolumn, I should be able to get only checked values, since these are the values I should store in an string array. How can I do this?
推荐答案
尝试一下:
Try This:
For Each dgrow As DataGridViewRow In dgrid.Rows
If Not IsDBNull(dgrow.Cells("CheckBoxColumnName").Value) Then
If dgrow.Cells("CheckBoxColumnName").Value = True Then
--add values to string array
End if
End If
Next
您需要遍历DataGridView行,对于每一行,将感兴趣的列中的单元格强制转换为DataGridViewCheckBoxCell
,并将Value
强制转换为bool
.
这是一个示例: http://social.msdn.microsoft.com/Forums/zh-CN/winformsdatacontrols/thread/31c7a954-1a85-4c38-9e9f-e157d33faf0 [
You need to iterate through the DataGridView rows and for each row, cast the cell in the column of interest toDataGridViewCheckBoxCell
and cast theValue
to abool
.
Here''s sort of an example: http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/31c7a954-1a85-4c38-9e9f-e157d33faf0[^]
这篇关于Datagridviewcheckbox列的检查值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文