how to sum the values of a single windows form datagrid column
-
I would like to know how to loop the values of int of a single column of a datagrid (windows forms) and sum them. C#
Hope that this will help.:)
CurrencyManager cm = (CurrencyManager)grid.BindingContext[grid.DataSource,grid.DataMember]; int numRows = cm.Count ; DataView dv = (DataView)cm.List ; string cols=string.Empty ; for(int i = 0 ; i < cm.Count ; i++) { //get sum here using dv[i][ColumnName]; }
sorry for my bad English.
-
Hope that this will help.:)
CurrencyManager cm = (CurrencyManager)grid.BindingContext[grid.DataSource,grid.DataMember]; int numRows = cm.Count ; DataView dv = (DataView)cm.List ; string cols=string.Empty ; for(int i = 0 ; i < cm.Count ; i++) { //get sum here using dv[i][ColumnName]; }
sorry for my bad English.
-
I've managed to do it myself but anyway thanks very much :) P.S. sorry for my English too. choopie