Michael,
You can reference the columns in the same way that it can be done in the CalcManager (which incidentally you need on the form to use a FormulaCondition). I'm assuming that you're doing this in code with an unbound column, so you could do the following, adding the conditions in the order in which they should be applied:
private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e){ ConditionValueAppearance cva = new ConditionValueAppearance(); FormulaCondition condition = new FormulaCondition(e.Layout.Bands[0].Columns["ID"], "and( [DateIn] != dbnull() , [DateOut] != dbnull() )"); Infragistics.Win.Appearance appearance = new Infragistics.Win.Appearance(); appearance.BackColor = Color.Green; cva.Add(condition, appearance); condition = new FormulaCondition(e.Layout.Bands[0].Columns["ID"], "and( [DateIn] != dbnull() , [DateOut] = dbnull() )"); appearance = new Infragistics.Win.Appearance(); appearance.BackColor = Color.Yellow; cva.Add(condition, appearance); condition = new FormulaCondition(e.Layout.Bands[0].Columns["ID"], "and( [DateIn] = dbnull() , [DateOut] = dbnull() )"); appearance = new Infragistics.Win.Appearance(); appearance.BackColor = Color.Red; cva.Add(condition, appearance); e.Layout.Bands[0].Columns["ID"].ValueBasedAppearance = cva;}
This code works under the assumption that it is the ID column that you want to set the appearances on. You may find it helpful when creating formulas to do it at design-time, even if you don't have the column available there that you want, just so that you can use the designer dialog, which provides a list of the functions and available columns.
-Matt
Hi, I am trying to set some conditional formatting on a column based on the value of another column.
Basically, I want that is a nullable boolean is false, the text in the second column is striked out. When the boolean is NULL, I want the text to be grayed out.
I am using the following code, however, the conditional appearance isn't triggered:
FormulaCondition denyCondition = new FormulaCondition(columnDescription); denyCondition.Formula = "([Column1] = False)"; FormulaCondition emptyCondition = new FormulaCondition(columnDescription); emptyCondition.Formula = "([Column1] = null)";
Appearance denyAppearance = new Appearance(); denyAppearance.FontData.Strikeout = DefaultableBoolean.True; Appearance emptyAppearance = new Appearance(); emptyAppearance.ForeColor = Color.LightGray;
ConditionValueAppearance condValApp = new ConditionValueAppearance();
condValApp.Add(denyCondition, denyAppearance); condValApp.Add(emptyCondition, emptyAppearance);
__grid.DisplayLayout.Bands[0].Columns["Description"].ValueBasedAppearance = condValApp;
What am I doing wrong?
Thx