
我创建了一个用于创建账单的datagridview。现在我想要添加所有列4的值。我该怎么做呢?
发布于 2013-08-24 19:23:58
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
If e.ColumnIndex = 1 Then // here your columnindex
calctotal()
End If
End Sub
Private Sub calctotal()
Dim tot As Single
For Each rw As DataGridViewRow In DataGridView1.Rows
If rw.Cells(0).Value <> "" Then
If String.IsNullOrEmpty(tot) Then
tot = Val(rw.Cells(0).Value) * Val(rw.Cells(1).Value)
Else
tot = tot + Val(rw.Cells(0).Value) * Val(rw.Cells(1).Value)
End If
Label1.Text = tot
End If
Next
End Subhttps://stackoverflow.com/questions/18417333
复制相似问题