Hi!
I'm using the UltraGrid (in namespace Infragistics.Win.UltraWinGrid) and I want to sum all the values (integers) in a certain column in the grid and put the result in a textbox (not in an extra row in the grid!). How do I do that?
I'm using version 6.2.
Regards, Emelia
What you would do is create an unbound column in the grid and give it a formula using the "IF" function so that you give the unbound cell a value or 0 based on the u_id. Then you sum the unbound column.
What if I only want to sum certain rows in the column?
Say I have 10 rows in the column but only want to sum 5 of them and display it in a textbox? They do have a u_id, so how do I say "only sum these u_ids together"?
Found it,
I was binding the datatable to the grid by doing dgvWOVals.DataSource = <DataTable>, which overrides the schema. Therefore in the formula the Band key has to be replaced with the table name, so in my case that would be
"sum([//dgvWOVals/Valuations/MV] )"
instead of
"sum([//dgvWOVals/Band 0/MV] )"
Thanks for the reply, though.
Hi,
I tried this out using an unbound column in the grid and basically the same formula you are using and it works fine for me.
My only guess here is that something on your form has gotten corrupted and the grid is not properly hooked up to the calculation network.
If you look at your form's Designer code in the InitializeComponent method, make sure there is a line of code in there that sets the CalcManager property of the grid. Something like this:
this.ultraGrid1.CalcManager = this.ultraCalcManager1;
I've tried doing what you suggested, but I get an "Invalid or unavailable reference" error.
I have an UltraGrid called dgvWOVals where I manually define column MV of type Double. I also have a TextBox where I want to show the sum of MV. I can see the grid in the Formula Builder and I can reference the relevant column, however if I add the formula "sum([//dgvWOVals/Band 0/MV] )" to the TextBox I get the error.
I've tried the same thing using DataGridView and it worked, but I need to use UltraGrid because I need to create calculated columns and drive some of the other calculations off them.
Also, because UltraGrid loses all settings when the Data Schema is changed, I tend to do all formatting, binding and all calculated columns at run time. Will I still be able to reference columns created at run time through UltraCalcManager.
As a general statement I find that UltraCalcManager only works under some strict conditions and fails if any of the conditions are not met. Is there a good tutorial outlining when it will and will not work?
Thank you