2012-01-30 98 views
0

我有3列數量,價格和金額,我需要使用DataGridView計算每行的金額,我可能會使用哪些可能的事件?如何使用DataGridView計算單元格

+0

地鐵?的WinForms? WPF? Silverlight的? ASP.Net? MonoTouch的? – SLaks 2012-01-30 02:09:14

+0

WinForms Sir :) – Dennis 2012-01-30 02:14:33

回答

1

我認爲數量是Cell 0,價格爲Cell 1,並且量Cell 2

For i As Integer = 0 To DataGridView1.RowCount - 1 
    Dim xQty as Double = CDBL(DataGridView1.Rows(i).Cells(0).Value) 
    Dim xPrc as Double = CDBL(DataGridView1.Rows(i).Cells(1).Value) 
    DataGridView1.Rows(i).Cells(2).Value = xQty * xPrc 
Next