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 ). Use the Valid
property checks 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.

Send comments on this topic. © 1999-2017 Exontrol.COM, Software. All rights reserved.

The expression may be a combination of variables, constants, strings, dates and operators. A string is delimited by ", ` or ' characters, and inside they can have the starting character preceded by \ character, ie "\"This is a quote\"". A date is delimited by two # characters, ie #1/31/2001 10:00# means the January 31th, 2001, 10:00 AM.

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

**%0**,**%1**,**%2**,**%C0**,**%C1**,**%C2**,**%CD0**,**%CD1**,**%CD2**,**%CS0**,**%CS1**,**%CS2**,

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:

G2antt1.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_g2antt.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:

AxG2antt1.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:

axG2antt1.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.G2antt1.ConditionalFormats.Add("%0+%1>0").Bold = .t.

Send comments on this topic. © 1999-2017 Exontrol.COM, Software. All rights reserved.