我有一个简单的问题,有两个datagridviews,其中一个是
id Dealer code Sales
1 aaaa 121 1
2 bbbb 131 1
3 aaaa 121 1
4 aaaa 121 1
5 bbbb 131 1
在第二个datagridview中:
id Dealer Code Sales
1 aaaa 121
2 bbbb 131
我正在通过单击行并逐行更新来更新Sales列。
Dim a = (From row In DataGridView1.Rows.Cast(Of DataGridViewRow)() Where Convert.ToString(row.Cells(2).Value).Equals(TargetsDataGridView.CurrentRow.Cells(9).Value.ToString) Select row).Count
TargetsDataGridView.CurrentRow.Cells(6).Value = a
问题:是否可以通过按一个按钮来更新它?
我尝试过:
For i As Integer = 0 To TargetsDataGridView.Rows.Count - 1
Dim a = (From row In DataGridView1.Rows.Cast(Of DataGridViewRow)() Where Convert.ToString(row.Cells(1).Value).Equals(TargetsDataGridView.Rows(i).Cells(2).Value.ToString) Select row).Count
TargetsDataGridView.Rows(i).Cells(6).Value = a
Next
但它不起作用,需要你的帮助。感谢。