public enum ResultEnum : short
Open = 1,
Won = 2,
Lost = 3,
Void = 4,
DeadHeat = 5
}
I want to set the cell's Forecolor to Green if the Result is WON and to Red if the Result is LOST. Since the DataType of the column is set to the enum above, in the ValueBasedAppearance designer window, when I try to add a Operator Condition, I am not able to assign a value as whatever I type is treated as a string. I added a formula condition [Result] = 2 (for Won) and [Result] = 3 (for Lost) and that works. Is there a way I can use the Enumeration values instead of having to type the integer values?
sureshg1972 said:I added a formula condition [Result] = 2 (for Won) and [Result] = 3 (for Lost) and that works. Is there a way I can use the Enumeration values instead of having to type the integer values?
Yes and no.
The CalcManager can't access your enum. But you could define your enum for the CalcManager using NamedReferences.
What I would do is establish some sort of naming convention for the enum, like "ResultEnum_Open", "ResultEnum_Won", "ResultEnum_Lost", etc. Use these names in your formulas. Then at run-time, you use enum.GetValues to get all the possible values of the enum and loop through them and add a NamedReference to the CalcManager for each one using the naming convention and the value of the enum. You will want to do this at run-time, because that way you don't have to update it if you change the enum.
Thanks for the workaround Mike. I did what you suggested above for Enum.
Another related question... I've another column which is bound to decimal? (Nullable Type - refer http://msdn2.microsoft.com/en-us/library/2cf62fcy(VS.80).aspx ). I'm unable to set the ValueBasedAppearance of that column. I want to set the ForeColor to Green if the value is positive and to Red if the value is negative. Could you tell me how to do it?
Um... why exactly are you "unable to set the ValueBasedAppearance". What's the problem?
1) This looks like a bug. Perhaps the code isn't properly handling nullable types. You should Submit an incident to Infragistics Developer Support
2) The correct syntax for a formula is:
[ConditionValue] > 0.0
1. When I try to add an operator condition, I get the following error:
---------------------------Data Error---------------------------Unable to update the data value: Invalid cast from 'System.String' to 'System.Nullable`1[[System.Decimal, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'.---------------------------OK ---------------------------
2. When I try to add a formula condition, I don't see the formatting. I tried the following formulae but none of them worked. Is there a cheat sheet or reference for the syntax for formula editor:
[//ultraGrid1/Trades/NetProfit] > 0.0
[NetProfit] > 0.0
[NetProfit] > 0
[NetProfit.Value] > 0.0