Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
565
Summing a row on an UltraGrid
posted

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.

  • 17259
    Suggested Answer
    Offline posted

    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.