我需要有关数据网格和列表框的帮助 [英] I need some help with datagrid and listbox
本文介绍了我需要有关数据网格和列表框的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是,当我按下按钮时,我在数据网格中检查的项目没有出现在列表框中,而是在数据网格中未选择的项目出现在了列表框中,所以它们互换了.
这是我的代码:我的按钮只需调用此函数
谁能帮我一下:(
任何帮助将不胜感激:)
My problem is that the items I checked in the datagrid do not appear in the listbox when I press the button, rather the items that are not selected in the datagrid appear in the listbox,so they interchanged.
Here is my code: my button just call this function
Can anyone help me please :(
Any help would be appreciated :)
Public Sub TestThis()
Dim A1 As Integer = dtg1.RowCount - 2
Dim A As Integer
With dtg1
For A = 0 To A1
If .Item(2, A).Value = 0 Then
If .Item(0, A).Value.ToString <> "" Then
ListBox1.Items.Add(.Item(0, A).Value.ToString)
End If
End If
Next
End With
End Sub
推荐答案
尝试将.item(2,A).value=0
更改为.item(2,A).value<>0
0通常表示false,因此您正在检查是否未选中该项目
(假设.item(2,A)获得数据网格行的检查状态)
Try changing the.item(2,A).value=0
to.item(2,A).value<>0
0 usually means false so you are checking if the item isn''t checked
(Assuming .item(2,A) gets the checked state of the datagrid row)
Public Sub TestThis()
Dim A1 As Integer = dtg1.RowCount - 2
Dim A As Integer
With dtg1
For A = 0 To A1
If .Item(2, A).Value <> 0 Then
If .Item(0, A).Value.ToString <> "" Then
ListBox1.Items.Add(.Item(0, A).Value.ToString)
End If
End If
Next
End With
End Sub
这篇关于我需要有关数据网格和列表框的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文