ITabFormatConditions.Add

Syntax

Add: ITabFormatCondition;

Description

The Add method adds a new conditional format and returns a reference to it.

Example

Executing the example requires a form. Place on the form the components: Button, TabSheetBox, UiTabSheet named Button1, TabSheetBox1, and UiTabSheet1, respectively. Set the Source property to UiTabSheet1 for the TabSheetBox component.

Add links to the Drawing, ExtCtrls, Forms, and Tab system assemblies.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Tab: ITabSheet;
    Range: ITabRange;
    Conds: ITabFormatConditions;
    Cond: ITabFormatCondition;
    ValFormat: ITabFormatCellContent;
    Style: ITabCellStyle;
Begin
    Style := New TabCellStyle.Create;
    Style.Font.Color := GxColor.FromName("White");
    Style.BackgroundBrush := New GxSolidBrush.Create(GxColor.FromName("Black"));
    Tab := TabSheetBox1.Source.GetTabSheet;
    // Get cell range
    Range := Tab.ParseRange("A0:D3");
    // Conditional formats of cell range
    Conds := Range.FormatConditions;
    // Disable the use of conditional formats
    Conds.BeginUpdate;
    Debug.WriteLine("Disable the use of conditional formats: " + Conds.IsInUpdate.ToString);
    // Add conditional format
    Cond := Conds.Add;
    Cond.Type := TabConditionType.CellContent;
    ValFormat := Cond.Details As ITabFormatCellContent;
    ValFormat.ContentType := TabFormatContentType.CellValue;
    ValFormat.ValueCondition := TabConditionCellContentValue.Above;
    ValFormat.CellValue := 50;
    ValFormat.Style := Style;
    //...
    // Further setup of other conditional formats
    //...
    // Apply changes in conditional formats
    Conds.EndUpdate;
End Sub Button1OnClick;

After executing the example, when the button is clicked, a conditional format that formats cells with definite values is added for the selected cell range. Cell values greater than "50" are displayed in the white font on the black background.

See also:

ITabFormatConditions