AppliedRange: ITabRange;
The AppliedRange property determines the cell range with applied conditional formatting.
To set up conditional formatting, use the ITabFormatCellContent interface.
To get the list of formatting conditionsthat are used for a cell or cell range, use ITabRange.AppliedFormatConditions.
Executing the example requires a form with a set of components:
Button. The component implementing the button named Button1.
UiTabSheet. The component that is a data source for the TabSheetBox component named UiTabSheet1.
TabSheetBox. The component displaying a table named TabSheetBox1. Select the UiTabSheet1 data source in the Source property for the component.
Memo. The component that is a multisheet text editor named Memo1.
Add links to the Tab, Forms, and Drawing system assemblies.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
TSheet: ITabSheet;
Range: ITabRange;
FormCond: ITabFormatCondition;
ValFormat: ITabFormatCellContent;
Style: ITabCellStyle;
Format: ITabFormatConditions;
Begin
// Add values to the table
TSheet:= UiTabSheet1.TabSheet;
TSheet.Cell(0, 0).Value := 5;
TSheet.Cell(1, 0).Value := 6;
TSheet.Cell(2, 0).Value := 2;
TSheet.Cell(3, 0).Value := 7;
// Select a column with added values
TSheet.View.Selection.SelectColumns;
// Add a conditional formatting for selected values
TSheet := TabSheetBox1.Source.GetTabSheet;
Range := TSheet.View.Selection.Range;
FormCond := Range.FormatConditions.Add;
FormCond.Type := TabConditionType.CellContent;
ValFormat := FormCond.Details As ITabFormatCellContent;
// Set the Cell Value Is Greater Than Five condition
ValFormat.ContentType := TabFormatContentType.CellValue;
ValFormat.ValueCondition := TabConditionCellContentValue.Above;
ValFormat.CellValue := 5;
// Create a style for cells where condition is applied
Style := New TabCellStyle.Create;
Style.BackgroundColor := GxColor.FromName("Yellow");
ValFormat.Style := Style;
// Determine addresses of cells where condition is applied
Format := Range.FormatConditions;
FormCond := Format.Item(0);
Memo1.Text := FormCond.AppliedRange.Address;
End Sub Button1OnClick;
Clicking the button displays the conditional formatting for specified values in the table:
All values that are greater than five will be highlighted with yellow.
Addresses of cells where formatting condition is applied will be contained in the Memo1 component.
See also: