Peter Dzuya

Peter Dzuya

  • NA
  • 313
  • 39.5k

Traversing through Rows in a grid

Aug 31 2016 2:50 PM
 
Hi All, 
I wish to sum up all credits that I have already filtered in a grid. I have written this code as shown below:-
 
DevExpress.XtraGrid.Columns.GridColumn col = View.Columns.ColumnByFieldName("Credit");
if (col == null)return;
View.BeginSort();
try
{
int dataRowCount = View.DataRowCount;
for (int i = 0; i < dataRowCount; i++)
{
object cellValue = View.GetRowCellValue(i, col);
decimal totalcredit = Convert.ToDecimal(cellValue);
barEditItemCredit.EditValue += totalcredit;
}
}finally{
View.EndSort();
}
 
 when I run the program, I get the below exception.
 
Cannot apply operator "+=" to operands of type 'Object' and 'Decimal' 
 
 
Please assist.
Thanks
Peter 

Answers (2)