property ConditionalFormat.Expression as String

Indicates the expression being used in the conditional format.

Type | Description | |||

String | A formal expression that indicates the formula being used in formatting. For instance, "%0+%1>%2", highlights the cells or the items, when the sum between first two columns is greater than the value in the third column |

The
conditional formatting feature allows you to apply formats to a cell or range
of cells, and have that formatting change depending on the value of the cell
or the value of a formula. The Expression property specifies a formula that indicates
the criteria to format the items or the columns. Use the ApplyTo
property to specify when the items or the columns are formatted. Use the
Add method to specify the expression
at adding time. The Expression property may include variables, constants,
operators or ( ) parenthesis. A variable is defined as %n, where n is
the index of the column ( zero based ). For instance, the %0 indicates the
first column, the %1, indicates the second column, and so on. A constant
is a float expression ( for instance, 23.45 ). The Valid
property specifies whether the expression is syntactically correct, and can be
evaluated. If the expression contains a variable that is not known, 0 value is
used instead. For instance, if your control has 2 columns, and the expression
looks like "%2 +%1 ", the %2 does not exist, 0 is used instead. When
the control contains two columns the known variables are %0 and %1.

*The expression supports cell's identifiers as follows:*

**%0**,**%1**,**%2**,

This property/method supports predefined constants and operators/functions as described here.

*Samples:*

- "
**1**", highlights all cells or items. Use this form, when you need to highlight all cells or items in the column or control. - "
**%0 >= 0**", highlights the cells or items, when the cells in the first column have the value greater or equal with zero - "
**%0 = 1 and %1 = 0**", highlights the cells or items, when the cells in the first column have the value equal with 0, and the cells in the second column have the value equal with 0 - "
**%0+%1>%2**", highlights the cells or the items, when the sum between first two columns is greater than the value in the third column - "
**%0+%1 > %2+%3**", highlights the cells or items, when the sum between first two columns is greater than the sum between third and forth column. - "
**%0+%1 >= 0 and (%2+%3)/2 < %4-5**", highlights the cells or the items, when the sum between first two columns is greater than 0 and the half of the sum between third and forth columns is less than fifth column minus 5. - "
**%0 startwith 'A'**" specifies the cells that starts with A - "
**%0 endwith 'Bc'**" specifies the cells that ends with Bc - "
**%0 contains 'aBc'**" specifies the cells that contains the aBc string - "
**lower(%0) contains 'abc'**" specifies the cells that contains the abc, AbC, ABC, and so on - "
**upper(%0)**'" retrieves the uppercase string - "
**len(%0)>0**'" specifies the not blanks cells - "
**len(%0)=0**'" specifies the blanks cells

The conditional format feature may change the cells and items as follows:

- Bold property. Bolds the cell or items
- Italic property. Indicates whether the cells or items should appear in italic.
- StrikeOut property. Indicates whether the cells or items should appear in strikeout.
- Underline property. Underlines the cells or items
- Font property. Changes the font for cells or items.
- BackColor property. Changes the background color for cells or items, supports skins as well.
- ForeColor property. Changes the foreground color for cells or items.

The following VB samples bolds all items when the sum between first two columns is greater than 0:

ComboBox1.ConditionalFormats.Add("%0+%1>0").Bold = True

The following C++ sample bolds all items when the sum between first two columns is greater than 0:

COleVariant vtEmpty; m_combobox.GetConditionalFormats().Add( "%0+%1>0", vtEmpty ).SetBold( TRUE );

The following VB.NET sample bolds all items when the sum between first two columns is greater than 0:

AxComboBox1.ConditionalFormats.Add("%0+%1>0").Bold = True

The following C# sample bolds all items when the sum between first two columns is greater than 0:

axComboBox1.ConditionalFormats.Add("%0+%1>0", null).Bold = true

The following VFP sample bolds all items when the sum between first two columns is greater than 0:

thisform.ComboBox1.ConditionalFormats.Add("%0+%1>0").Bold = .t.