Hello, I am setting my grid's datasource to a dataset object returned from a sql stored procedure.
In the grid's initialize layout I wire-up the calc manager:
this
.ugCommentary2.CalcManager = this.ultraCalcManager1;
I then wire-up a formula in one of the grid's columns:
e.Layout.Bands[0].Columns[
"MTD Gross Attribution"].Formula = string.Format("( ROUNDUP((([MTD % Contribution] * {0}) * 100),2) )",numGrossRetMTD.Text);
This works great, but only when you set the grid's datasource. "numGrossRetMTD" (above) is my UltraNumericEditior control. *My goal is to have all formula's in the grid re-fire every time a value is updated in the numeric editor control.
Just looking for the cleanest way to accomplish this. Many thanks in advance!
PS - I also tried adding the editor control to the calc settings in my form load event:
Infragistics.Win.UltraWinCalcManager.CalcSettings calcSettings = new Infragistics.Win.UltraWinCalcManager.CalcSettings();
calcSettings.PropertyName = "GrossRetMTD";
calcSettings.TreatAsType =
typeof(double);
.ultraCalcManager1.SetCalcSettings(this.numGrossRetMTD, calcSettings);
...but I have a feeling this was a pathetic attempt...
To summarize as a solution to adding calc manager formulas to grid columns with other control values as participating in the formulas:
First add the other controls (in this case an ultraNumericEditor) to the CalcNetwork in the contructor or form load event: ("Value" is the ultraNumericEditor1.Value property)
CalcSettings cs = new CalcSettings();cs.PropertyName = "Value";cs.TreatAsType = typeof(double);this.ultraCalcManager1.SetCalcSettings(this.ultraNumericEditor1, cs);
cs = new CalcSettings();cs.PropertyName = "Value";cs.TreatAsType = typeof(double);this.ultraCalcManager1.SetCalcSettings(this.ultraNumericEditor2, cs);
Now wire your grid to ultraCalcManager1 in the InitializeLayout event:
this.ultraWinGrid.CalcManager = this.ultraCalcManager1;
Finally, set a formula on a given column in the same InitializeLayout event: (*Note the reference syntax to your control containing the value to partcipate in the calculation uses forward slashes [//ultraNumericEditor1])
e.Layout.Bands[0].Columns["MyDataSetColumnName"].Formula = "( ROUNDUP((([OtherColumnNameInGridWithNoQuotesHere] * [//ultraNumericEditor1]) * 100),2) )";
Regards, Jaime
Solved! Changed calcSettings.PropertyName to "Value" (of the control) not "Text" and the validation errors are gone and the calculations in both grids update upon changing the text in the control.
Mike, thanks again - you led me down the right path.
More on the numeric editor validation prompt mentioned at the end of my last post - The pesky red exclamation point icon goes away when focus leaves the control and the #Ref! in each column also resolve to properly calculated values using the new value in the numeric editor, but only after I click one of the cells in each column. There must be an easy way to remedy each of these. Thanks again, Jaime
Hey Mike, I've used so many of your posts that it is nice that you are the one responding to my first.
I had previously tried something like what you suggest (but did not want to write a novel in the initial post) where I created a method called from the form load event. The method contained these 4 lines"
Infragistics.Win.UltraWinCalcManager.CalcSettings calcSettings = new Infragistics.Win.UltraWinCalcManager.CalcSettings();calcSettings.PropertyName = "GrossRetMTD";calcSettings.TreatAsType = typeof(double);this.ultraCalcManager1.SetCalcSettings(this.numGrossRetMTD, calcSettings);
Seeing your post I immediately thought that the issue was with the formula because I had forward slashes in front of the control name, not backslashes in your emample above. [//numGrossRetMTD] vs. [\\numGrossRetMTD].
It does not work as I get #REF! in each cell with the formula. The interesting part is when I do have forward slashes before the control name [//numGrossRetMTD] I get a validation prompt (flashing red exclamation point) on the numGrossRetMTD control that states, "PropertyName not set or property not found on CalcSettings". This tells me that the forward slashes are correct, so I changed the four lines above to what you suggested:
CalcSettings calcSettings = this.ultraCalcManager1.GetCalcSettings(this.ultraNumericEditor1);calcSettings.PropertyName = "Text";calcSettings.TreatAsType = typeof(double);
This works on the intial load (yea!) but upon changing the value in ultraNumericEditor1, I now get an immediate validation prompt, "Input String was not in a correct format"...? I get no such prompt when I comment out the code to add the control to the CalcNetwork. What next? We're close!
Hi,
The problem here is that you are hard-coding your formula with the current value (text) of the Numeric editor, rather than actually referring to the UltraNumericEditor in the formula itself.
The proper way to do this is like so:
.Formula ="( ROUNDUP((([MTD % Contribution] * [\\numGrossRetMTD]) * 100),2) )";
You probably also need to make sure that the NumericEditor is added to the CalcNetwork. The easiest way to do this is to go to the NumericEditor control at design-time and edit the CalcSettings.PropertyName and set it to Text.
But you seem to be doing all of this at run-time. So you could do it like this:
CalcSettings calcSettings = this.ultraCalcManager1.GetCalcSettings(this.ultraNumericEditor1); calcSettings.PropertyName = "Text"; calcSettings.TreatAsType = typeof(double);