TdxSpreadSheetCustomConditionalFormatting.BeginUpdate Method
Postpones all redraw operations that reflect appearance changes in the parent control until an EndUpdate procedure call.
#Declaration
procedure BeginUpdate;
#Remarks
Every time you manage conditional formatting rules or change their settings, the parent control redraws its content to reflect the change. Enclose multiple conditional formatting rule changes between BeginUpdate
and EndUpdate procedure calls to avoid UI flickering due to excessive redraw operations and improve performance.
#BeginUpdate/EndUpdate Procedure Calls and Batch Changes
A BeginUpdate
procedure call disables notifications and postpones all changes until an EndUpdate call. A subsequent EndUpdate call does the following:
- Re-enables change notifications and corresponding redraw operations in the parent control
- Applies all changes made after a
BeginUpdate
call - Sends corresponding notifications in a batch
- Redraws the parent control
Note
Ensure that every Begin
procedure call is followed by an End
#Code Example: Create and Configure Two Conditional Formatting Rules
The following code example creates Duplicate and Unique value conditional formatting rules with different custom cell styles and applies these rules to the last selected cell range in the active worksheet in a TdxSpreadSheet control:
var
ATableView: TdxSpreadSheetTableView;
ADuplicateValuesRule: TdxSpreadSheetConditionalFormattingRuleDuplicateValues;
AUniqueValuesRule: TdxSpreadSheetConditionalFormattingRuleUniqueValues;
begin
ATableView := dxSpreadSheet1.ActiveSheetAsTable;
if ATableView.Selection.Count = 0 then Exit;
ATableView.ConditionalFormatting.BeginUpdate; // Initiates the following batch change
try
ATableView.ConditionalFormatting.Add(ATableView.Selection.Area,
TdxSpreadSheetConditionalFormattingRuleDuplicateValues, ADuplicateValuesRule);
ADuplicateValuesRule.Style.Brush.BackgroundColor := clBlue;
ADuplicateValuesRule.Style.Brush.ForegroundColor := clNavy;
ADuplicateValuesRule.Style.Brush.Style := sscfsRevDiagonalStrip;
ADuplicateValuesRule.Style.Font.Color := clWhite;
ADuplicateValuesRule.Style.Font.Style := [fsBold, fsItalic];
ATableView.ConditionalFormatting.Add(ATableView.Selection.Area,
TdxSpreadSheetConditionalFormattingRuleUniqueValues, AUniqueValuesRule);
AUniqueValuesRule.Style.Brush.BackgroundColor := clLime;
AUniqueValuesRule.Style.Brush.ForegroundColor := clGreen;
AUniqueValuesRule.Style.Brush.Style := sscfsDiagonalStrip;
AUniqueValuesRule.Style.Font.Color := clWhite;
AUniqueValuesRule.Style.Font.Style := [fsBold];
finally
ATableView.ConditionalFormatting.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;