Hello,
I have some issues with UltraCalcManager.
First of all is there any away to perform an numeric actions between strings?( +, -, etc.) ("aaa"+"bbb" = "aaabbb")
Also I am trying to use the manager with an infragistics grid which contains columns of custom data type.
The showed values of these columns are numeric.
I want to perform actions between them (+, -, *, etc.)
However because of the custom datatypes the manager handles the values as strings.
Is there any way I can cast these columns?
CalcManager knows how to deal with strings, date, and numbers (doubles). If you are using a custom data type that cannot be converted into one of those, then you will probably have to do a little extra coding.
As Divya mentioned, you could use an unbound column. For example, if you have a class that contains a numeric value, you could use the grid's InitializeRow event to copy that value into an unbound numeric column and then perform your calculations on THAT column instead of on the object.
If your custom object is a class you can modify, you can try implementing IConvertible. I think the CalcManager might try to call into IConvertible to convert the object into a double if it supports that interface, although I am not 100% sure.
Another option would be to write your own custom calc functions that know about your custom class and how to perform calculations on it. You can register your own custom functions that are either completely new or override the existing functions in the CalcManager.
Is there any way that I can do calculation between custom objects? Could I have an example of custom calc function
?
I'm not exactly clear on what you want to do. It is possible to write your own UltraCalcReference objects to represent your own custom objects in the calculation engine. But this would be extremely complex and difficult and I would not recommend it.
A much simpler way would be to use the UltraCalcManager.NamedReferences collection. You can add a reference to the list and apply a formula to it. Then, whenever the value of your custom object changes, you would simply update the values in that formula. And you could trap for when the formula is recalculated and get the result using the CalculationsCompleted event.
If this question is related to your other thread about validating formulas then I don't think this will really help you.
Hello Mike,
Thanks for your answer.
As I mention on topic start, I have some custom objects (Length) which are presented on grid as numeric's values.
IConvertible worked correctly on the situation when I want to something between the custom object and a number.
( like: [customObjectColumn] + 1 )
However when I want to do something like ([customObjectColumn1] + [customObjectColumn2]) I get a #REF error and seems like IConvertible are not being called.
Any idea how something like this could work?
Hi,
I tried this out and both "[customObjectColumn] + 1" and "[customObjectColumn1] + [customObjectColumn2]" work fine for me.
I am attaching my sample here. WindowsFormsApplication52.zip