我想使用此代码在数据 GridView 列中查找并求和搜索 ID 的数量值
Dim tqty As Double
For Each row As DataGridViewRow In dgv.Rows
If row.Cells.Item(0).Value = cmbItemCode.Text Then
tqty += row.Cells.Item(4).Value
Textbox1.text=tqty
Exit For
End If
Next
问题在于 Textbox1
仅显示一个搜索最多的行值。例如
id item name qty
1 abc 4
2 xyz 10
1 abc 10
Textbox1
仅显示结果 4。
最佳答案
一旦达到第一个值,就会退出 for 语句。因此你永远不会传递第一个值。删除 Exit 因为它应该可以工作。
关于vb.net - 在 vb.net 中查找和求和 datagridview 列的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57438918/