Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to Add a Standalone Editor to a Toolbar

  • 2 minutes to read

In addition to built-in bar editors, the ExpressBars Suite also allows you to place standalone editors from the ExpressEditors library onto any toolbar or menu. This topic demonstrates how to add a standalone editor from this library to a toolbar at design and runtime.

To add an editor programmatically you need to:

The following code snippet adds a TcxCalcEdit, and it assumes that a bar named Custom 1 has already been added to the ExpressBars6MainForm form.

uses
  ..., cxCalc, cxBarEditItem;
procedure TExpressBars6MainForm.FormCreate(Sender: TObject);
var
  ABarManager : TdxBarManager;
  ABar : TdxBar;
  ABarEditItem: TcxBarEditItem;
begin
  ABarManager := GetBarManagerByForm(ExpressBars6MainForm);
  with ABarManager do
  begin
    ABar := BarByCaption('Custom 1');
    if ABar <> nil then
    begin
      BeginUpdate;
      try
        ABarEditItem := TcxBarEditItem(ABar.ItemLinks.AddItem(TcxBarEditItem).Item);
        with ABarEditItem do
        begin
          PropertiesClass := TcxCalcEditProperties;
          Caption := 'Calc Edit';
          ShowCaption := True;
        end;
      finally
        EndUpdate;
      end;
    end;
  end;
end;

The following image shows the result when the above code executes.

To add a standalone editor at design time, right-click the desired bar and choose Add cxEditItem and then select the appropriate editor type within the submenu (see the image below).

See Also