Skip to main content

TcxCustomEditProperties.EndUpdate(Boolean) Method

Applies all pending changes and redraws the editor after a BeginUpdate procedure call.

Declaration

procedure EndUpdate(AInvokeChanged: Boolean = True);

Parameters

Name Type Description
AInvokeChanged Boolean

Optional. Specifies if the procedure call immediately applies all pending changes:

  • If True (default), the procedure applies all pending changes and redraws the editor.
  • If False, the procedure only re-enables change notifications and redraw operations. All pending changes are delayed until the next content or editor setting change.

Refer to the following sections for additional information: Optional Parameter Usage Scenarios.

Remarks

Every time you change an editor setting, the editor redraws its content to reflect the change. Enclose multiple editor setting changes between BeginUpdate and EndUpdate procedure calls to avoid UI flickering due to excessive redraw operations and improve performance.

BeginUpdate/EndUpdate Calls and Batch Changes

A BeginUpdate procedure call disables notifications and postpones all changes until an EndUpdate call. A subsequent EndUpdate call with an omitted optional parameter does the following:

  • Re-enables change notifications and corresponding redraw operations
  • Applies all changes made after a BeginUpdate call
  • Sends corresponding notifications in a batch and raises the OnPropertiesChanged event
  • Redraws the editor

Note

Ensure that every BeginUpdate procedure call is followed by an EndUpdate call, even if an exception occurs. Otherwise, the editor remains frozen and unresponsive.

Optional Parameter Usage Scenarios

The optional AInvokeChanged parameter is designed for rare usage scenarios when you need to configure an editor while it is invisible. An EndUpdate procedure call may force massive layout recalculations in the UI thread depending on the editor type, its content, and the number of setting changes. This process may render the application UI temporarily unresponsive when it takes a noticeable amount of time.

If the target editor is invisible during this process, you may want to re-enable change notifications and delay the time-consuming apply changes operation until the next change made after an EndUpdate procedure call.

Code Example

The code example below demonstrates OnButtonClick and OnCreate event handlers.

The application form’s OnCreate event handler creates two additional embedded buttons in a TcxButtonEdit control and configures the appearance and behavior of all embedded buttons. The OnButtonClick event handler associates all created buttons with the editor’s functionality.

Note

This example uses a TcxImageList component with three SVG icons as a source of glyphs for the created buttons.

procedure TMyForm.cxButtonEdit1PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
var
  AEditor: TcxButtonEdit;
begin
  AEditor := Sender as TcxButtonEdit;
  if AButtonIndex = 0 then  // The first button clears the editor
    AEditor.Clear
  else if AButtonIndex = 1 then  // The second button selects content
    AEditor.SelectAll
  else if AButtonIndex = 2 then  // The third button hides or reveals content
  begin
    if AEditor.Properties.EchoMode = eemNormal then
      AEditor.Properties.EchoMode := eemPassword
    else
      AEditor.Properties.EchoMode := eemNormal;
  end;
end;

procedure TMyForm.FormCreate(Sender: TObject);
var
  AProperties: TcxButtonEditProperties;
  I: Integer;
begin
  cxButtonEdit1.ShowHint := True;  // Enables hints for the editor
  AProperties := cxButtonEdit1.Properties;
  AProperties.BeginUpdate;  // Initiates the following batch change
  try
    AProperties.Images := cxImageList1;  // Assigns the source of button glyphs
    // Create two additional buttons
    AProperties.Buttons.Add;
    AProperties.Buttons.Add;
    // Specify common button settings
    for I := 0 to AProperties.Buttons.Count - 1 do
    begin
      AProperties.Buttons.Items[I].Kind := bkGlyph;  // Changes the button content type to "glyph"
      AProperties.Buttons.Items[I].ImageIndex := I;  // Specifies image indexes in the source list
      AProperties.Buttons.Items[I].HotTrackMode := TcxEditButtonHotTrackMode.Editor;
    end;
    // Specify unique button settings
    AProperties.Buttons.Items[0].Hint := 'Clear';
    AProperties.Buttons.Items[1].Hint := 'Select All';
    AProperties.Buttons.Items[2].Hint := 'Hide/Reveal';
    AProperties.Buttons.Items[2].LeftAlignment := True;
    AProperties.Buttons.Items[2].Transparent := True;
  finally
    AProperties.EndUpdate;  // Calls EndUpdate regardless of the batch operation's success
  end;
end;

VCL Editors Library: An Editor with Three Custom Buttons

See Also