2013-04-09 57 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 
相關問題