2013-04-09 83 views

回答

0

这很直截了当。代码如果总和列是最后一个:

Dim sumRowIndex As Integer = DataGridView1.ColumnCount - 1 
    Dim sum As Double = 0 

    For Each row In DataGridView1.Rows 
     For collumn = 0 To DataGridView1.ColumnCount - 2 
      'check if cell value is a number 
      If Double.TryParse(row.Cells(collumn).Value, Nothing) Then 
       sum = sum + row.Cells(collumn).Value 
      End If 
     Next 
     row.Cells(sumRowIndex).Value = sum 
     sum = 0 
    Next 
相关问题