Can someone help me on how to sum up all the values in specific column in a DataGridView.
Name No. of Apples
Jayson 10
Troe 10
Edna 10
imagine this is the sample data in the Datagridview. how can i add all the Number of apples??? THANKS
Printable View
Can someone help me on how to sum up all the values in specific column in a DataGridView.
Name No. of Apples
Jayson 10
Troe 10
Edna 10
imagine this is the sample data in the Datagridview. how can i add all the Number of apples??? THANKS
Is this grid bound to a DataTable? If so then you'd call the table's Compute method, e.g.vb.net Code:
Dim sum As Integer = CInt(myDataTable.Compute("SUM(SomeColumn)", Nothing))
And if the datagridview is not bound, you'll have to manually loop through all its rows and add the values yourself.