ConditionGroup conditionGroup = new ConditionGroup(); OperatorCondition operatorConditionA; OperatorCondition operatorConditionB; ConditionValueAppearance CondValue = new ConditionValueAppearance(); Appearance condAppearance; object objValue1 = 10.1, objValue2 = 19.7; //Customize appearance condAppearance = new Infragistics.Win.Appearance(); condAppearance.BackColor = Color.White; condAppearance.ForeColor = Color.Blue; operatorConditionA = new OperatorCondition(ConditionOperator.GreaterThan, objValue1); operatorConditionB = new OperatorCondition(ConditionOperator.LessThan, objValue2); conditionGroup.Add(operatorConditionA); conditionGroup.Add(operatorConditionB); conditionGroup.CombineOperator = LogicalOperator.And; CondValue.Add(conditionGroup, condAppearance); UltraGrid1.DisplayLayout.Bands[0].Columns["Grade"].ValueBasedAppearance = CondValue; Assume I have the following values in column "Grade": { 7, 8, 10, 10.1, 10.2, 10.3, 15, 18, 19.6, 19.7, 19.9 } I set column decimal format to 0, so visible values become: { 7, 8, 10, 10, 10, 15, 18, 19, 19, 19 } I do the following conditional formatting and I obtain the following values affected: { 15, 18 } What I want is compeltely different, I want the conditional formatting to work on cell original value { 10.2, 10.3, 15, 18, 19.6 } and show me the following cells affected: { 10, 10, 15, 18, 19 }
I just tried this out and it worked correctly for me, in that I had {10, 10, 15, 18, 20 } all with a ForeColor of Blue (the last value was 20 since 19.6 was rounded up by the Format). What version of the controls are you using? It's possible that an issue was addressed in the latest service release for your version. For what it's worth, I added all that code in the InitializeLayout event, but I didn't actually change anything.
-Matt
Hi Matt,
I am using the version 9.1.20091.1000.
it's not working with me.
the case is when i have 10.9 which will be displayed as 11 (if I press F2 it will show 10.9) i tried to add the conditional formatting to color the values equal to 11, it wasn't colored
Can you post a sample project demonstrating the issue? As I had mentioned, I tried out the exact code that you had posted, with the only difference being that I had to create my own data source, with a Decimal column created that didn't happen to have the same name as your column. It may be possible that an issue was fixed in the latest service release, but I can't really say since I'm not sure what is preventing this from working for you.
Hi,
please find attached a sample. i have a grid containing numbers. i added a conditional formatting on the numbers greater than or equal 10.1. the cell showing 10.1 (which value is 10.108) wasnt affected. is there a way of doing this?
thx
Hi Hady,
I tried your sample. Initially, the sample only has a condition for LessThan or Equal to 10.1.It appears to work fine, the first 3 cells are highlighted.
When I comment out that condition and put in the one for GreaterThan, it again works fine for me. All except the first three rows are highlighted in yellow.
Hi Mike,
I guess i wasn't clear in my post.
the condition is lessThan or Equal to 10.1
the fourth cell's value is 10.108. but it's appearing as 10.1 due to the format applied.
so what i am facing is that the fourth cell is not highlighted. i just want to know if there is a way of doing that based on the text of the cell not the Value.
Oh, I see. No, I don't think there is any way to do that with conditional formatting.Except for the obvious way, which would be to change the value of the condition to a higher value. You could change it to 10.15, for example - assuming you know the formatting.
Another option might be to use the InitializeRow event instead of Conditional Formatting. Conditional Formatting is really designed to be used at run-time, anyway. It's actually more code to set it up at design-time than to use InitializeRow. In InitializeRow you could examine the Text property of the cell and use double.Parse to get a value from the text and use that as the basis of your condition instead of the actual cell Value.
Ah, okay. Well, that's a reason to use ConditionalFormatting, then. :)
hi Mike,
I want also to save the conditional formatting applied by the user. currently this is done by saving the layout of the grid.
If i use the initialize row, i guess it wont be save when saving the grid's layout.
Mike Saltzman said:Conditional Formatting is really designed to be used at run-time, anyway.
Oops. I meant to say "Conditional Formatting is really designed to be used at design-time, anyway."
Hady said:I am using the conditional formatting at run-time.
Yes, I understand that. But what I am saying is... using ConditionalFormatting is very convenient at design-time. But at run-time, it's more code that using InitializeRow and it also can't really do what you want here.
So why use it? You would be better off using InitializeRow. It would be less code and you would be able to do what you want to do.
I am using the conditional formatting at run-time.
i will try the first suggestion.. but i dont think it will work coz the values are not static.