问题描述
您好
我最近遇到了数据网格问题,尤其是复选框
我的问题是我有2个表单,都带有datagrid,并且都有需要勾选的复选框。当我勾选主表单中的一个复选框时,另一个复选框不会勾选。
我一直在测试这段代码,但没有运气。
Private Sub btnWVValidate_Click(sender as Object,e As EventArgs)处理btnWVValidate.Click
For i As Integer = 0 To GVWVorders.Rows.Count( ) - 1步+1
Dim check As Boolean = DGVWVorders.Rows(i).Cells(3).Value
Dim row As DataGridViewRow = DGVWVorders.Rows(i)
如果check = True然后
for j As Integer = 0 to frmCustomerOrderStatus.DGVOrderDetails.Rows.Count() - 1 Step +1
Dim check2 As Boolean = frmCustomerOrderStatus.DGVOrderDetails.Rows(j).Cells(1)。值
如果frmCustomerOrderStatus.DGVOrderDetails.Rows(j).Cells(1).Value = True则
否则
frmCustomerOrderStatus.DGVOrderDetails.Rows(j).Cells(1).Value = False
结束如果
下一个
结束如果
下一个
结束子
结束等级
请帮助, Vincent
编辑
我一直在努力改变编码:
Private Sub btnWVValidate_Click(sender as Object,e As EventArgs)处理btnWVValidate.Click
For i As Integer = 0 To DGVWVorders.Rows.Count() - 1 Step +1
Dim check As Boolean = DGVWVorders.Rows(i).Cells(3).Value
Dim row As DataGridViewRow = DGVWVorders.Rows(i)
如果check = True则
对于j As Integer = 0到frmCustomerOrderStatus.DGVOrderDetails.Rows.Count() - 1步+1
Dim check2 As Boolean = frmCustomerOrderStatus.DGVOrderDetails.Rows(j).Cells(1).Value
如果check2 = True则
frmCustomerOrderStatus.DGVOrderDetails.Rows(j).Cells(1)= T rue
Else
frmCustomerOrderStatus.DGVOrderDetails.Rows(j).Cells(1)= False
End if
Next
End if
Next
结束次级
结束等级
然而,两者都
frmCustomerOrderStatus.DGVOrderDetails。行(j)。细胞(1)=真
和
frmCustomerOrderStatus.DGVOrderDetails。行(j).Cells(1)= False
出现错误,其值不接受布尔值。
是否存在我的结构方式出错了吗?
- Vincent
Hello
I've been having an issue with datagrid lately, especially with check boxes
My issue is that I have 2 forms, both with datagrid, and both have checkboxes that need to be ticked. When I tick one checkbox in my main form, the other checkbox won't tick.
I've been testing with this code but have no luck.
Private Sub btnWVValidate_Click(sender As Object, e As EventArgs) Handles btnWVValidate.Click For i As Integer = 0 To GVWVorders.Rows.Count() - 1 Step +1 Dim check As Boolean = DGVWVorders.Rows(i).Cells(3).Value Dim row As DataGridViewRow = DGVWVorders.Rows(i) If check = True Then For j As Integer = 0 To frmCustomerOrderStatus.DGVOrderDetails.Rows.Count() - 1 Step +1 Dim check2 As Boolean = frmCustomerOrderStatus.DGVOrderDetails.Rows(j).Cells(1).Value If frmCustomerOrderStatus.DGVOrderDetails.Rows(j).Cells(1).Value = True Then Else frmCustomerOrderStatus.DGVOrderDetails.Rows(j).Cells(1).Value = False End If Next End If Next End Sub End Class
Please help, Vincent
EDIT
I've been trying for a bit and changed the coding around:
Private Sub btnWVValidate_Click(sender As Object, e As EventArgs) Handles btnWVValidate.Click For i As Integer = 0 To DGVWVorders.Rows.Count() - 1 Step +1 Dim check As Boolean = DGVWVorders.Rows(i).Cells(3).Value Dim row As DataGridViewRow = DGVWVorders.Rows(i) If check = True Then For j As Integer = 0 To frmCustomerOrderStatus.DGVOrderDetails.Rows.Count() - 1 Step +1 Dim check2 As Boolean = frmCustomerOrderStatus.DGVOrderDetails.Rows(j).Cells(1).Value If check2 = True Then frmCustomerOrderStatus.DGVOrderDetails.Rows(j).Cells(1) = True Else frmCustomerOrderStatus.DGVOrderDetails.Rows(j).Cells(1) = False End If Next End If Next End Sub End Class
However, both
frmCustomerOrderStatus.DGVOrderDetails.Rows(j).Cells(1) = True
and
frmCustomerOrderStatus.DGVOrderDetails.Rows(j).Cells(1) = False
come up with errors with the values not accepting the boolean.
Is there an error with the way I've structured it?
- Vincent
这篇关于一个数据网格中的勾选复选框未在另一个数据网格中勾选的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!