Add: ITabFormatCondition;
The Add method adds a new conditional format and returns a reference to it.
Executing the example requires a form. Place the following components on the form: Button named Button1, TabSheetBox named TabSheetBox1, and UiTabSheet named UiTabSheet1. For the TabSheetBox1 component set the Source property to UiTabSheet1.
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: