I'm really, really frustrated that I cannot find ANY information from Infragistics how to sum a row of data in a datagrid... NOT A COLUMN, A ROW! I know how to do column summaries...
I have an unbound grid that I don't know how many columns the row will have until run time.. How do I sum the values of the row and place them in the last column titled 'Total". Do I use Row_Initialize, UltraCalcManager (which I've never used..)... any help ??
This cannot be this difficult to accomplish!
Thanks.
You can easily do it with RowInitialize. In the event handler:
e.Row.Cells["Total"].Value = e.Row.GetCellValue(column1) + e.Row.GetCellValue(column2) ......
If setting the total value causing RowInitialize to fire again, you can disable the event temporarily before setting the value by using grid.EventManager.SetEnabled method.
Maybe there is a built-in solution for that that I'm not aware of.
Yeah, I thought of that also, problem I hit with it was you cannot use a foreach in the activerow to get the columns for that row...
Unless I'm missing something..
Snap.. Thanx.. That's what I needed.. I think I have it working now... Kudos to you and much thanks!!
Ofcourse you can.
foreach (var column in e.Row.Band.Columns)
or
e.Row.Band.Columns.OfType<UltraGridColumn>().Sum(c => e.Row.GetCellValue(c))