Looks like this isn't possible, I get an input not in correct format exception. I feel like the final result of a calculation should be allowed to return a string...
Is there any way to return a string from the result of a formula or will the UltraCalcManager always attempt to cast the result to a number? I'm trying to give my users the most complete coverage when it comes to creating their own reports by creating custom columns and one such request was to display certain text depending on the value of another column. As it is right now I have to implement this on the InitializeRow event whereas I'd like the end-user to have this functionality.
I'm still a little unclear on what you are trying to do. It is certainly possible to have a formula return a string. But it depends on the formula and what control is displaying the results. If the formula returns a number, it will usually be returned as a double. But there are certainly formulas and functions that return strings.
There's a function in Excel called Text which converts a number to a string, but it looks like there is no such function in CalcManager. But you could create your own custom function for this. It would be pretty simple.
I'm trying to test another column for a range of values and then return a string representing the category it is in. Even setting the formula of a column to something simple, below, resuts in the following exception:
'HY'
{"Input string was not in a correct format."}
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt) at System.Decimal.Parse(String s, NumberStyles style, IFormatProvider provider) at System.Convert.ToDecimal(String value, IFormatProvider provider) at System.String.System.IConvertible.ToDecimal(IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at Infragistics.Win.UltraWinGrid.UltraGridCell.SetValueInternal(Object value, Boolean suppressErrorMessagePrompt, Boolean fireInitializeRow, Boolean throwExceptionOnError) at Infragistics.Win.UltraWinGrid.UltraGridCell.SetValueInternal(Object value, Boolean suppressErrorMessagePrompt, Boolean fireInitializeRow) at Infragistics.Win.UltraWinGrid.CellReference.set_Value(UltraCalcValue value) at Infragistics.Win.CalcEngine.RangeCalcInfo.EvaluateNextRow() at Infragistics.Win.CalcEngine.UltraCalcEngine.Evaluate(Int64 ticks) at Infragistics.Win.CalcEngine.UltraCalcEngine.Recalc(Int64 ticks) at Infragistics.Win.UltraWinCalcManager.UltraCalcManager.ReCalcInternal(Int64 ticks) at Infragistics.Win.UltraWinCalcManager.UltraCalcManager.ReCalc(Int64 millis) at Infragistics.Win.UltraWinCalcManager.UltraCalcManager.ReCalcSynchronous() at Infragistics.Win.UltraWinCalcManager.UltraCalcManager.VerifyReCalc() at Infragistics.Win.UltraWinCalcManager.UltraCalcManager.Infragistics.Win.CalcEngine.IUltraCalcManager.AddFormula(IUltraCalcFormula formula) at Infragistics.Win.UltraWinGrid.FormulaRefBase.RegisterFormula(String newFormulaString) at Infragistics.Win.UltraWinGrid.FormulaHolder.ReaddFormulaToCalcNetwork() at Infragistics.Win.UltraWinGrid.UltraGridColumn.set_Formula(String value)
It sounds to me like the column's data type is a numeric type.
Yes, that would work but I have a lot of formatting built on the data type of the column. Our data is limited to numbers and strings so when I catch that exception I can just set the data type to string. Thanks for your help.
No, but why not set the column's data type to object?
That was simple enough, I suppose. I could offer my users the choice to select the data type of the column, numeric or string, but ideally I'd like to eliminate this step. Is there anyway to determine the resultant data type of a formula before assigning it to a column?