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
Yes, it is. :)
You can use CalcManager on any control. The CalcSettings allows you to apply a formula and you can even choose which property of the control the formula applies to.
Oooooo!!! I didn't know that: that's cool! :)
Actually, you don't need the NamedReference - you can apply a formula directly to the TextBox control using the CalcSettings property. This is an extender property that will show up in the property grid at design-time as long as there is an UltraCalcManager component on the form with the TextBox.
Also... I recommend using a Label, rather than a TextBox. Or making the TextBox read-only. Since any edits the user makes will be overwritten by the formula.
Add the UltraCalcManager to your form
Add a NamedReference to the UltraCalcManager NamedReferences collection. The formula will be something like sum( [//_grid/DataRecord/Qty] ), where "_grid" is the Id of the Grid, DataRecord is the Band name and Qty is the Column name.
_calcManager.NamedReferenceResultChanged += new Infragistics.Win.UltraWinCalcManager.NamedReferenceResultChangedEventHandler(OnSumQty_NamedReferenceResultChanged);
In the event handler, update your control
{
_sumQtyLabel.Text = e.NamedReference.FormulaResult.ToString();
}
Which methodes/properties shall I use to supply the UltraCalcManager with a named reference and a formula?