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 Arrange Toolbars

When a user moves toolbars at runtime, separations between individual toolbars may be created based on the placement of these toolbars. The following code demonstrates how you can arrange toolbars docked to a form’s top, to eliminate this free space.

// ...
procedure TMainForm.ArrangeBarsButtonClick(Sender: TObject);
var
  I, J, Offset: Integer;
  DockRow: TdxDockRow;
begin
  with dxBarManager do
  begin
    BeginUpdate;
    try
      for J := 0 to Bars.DockControls[dsTop].RowList.Count - 1 do
      begin
        DockRow := TdxDockRow(Bars.DockControls[dsTop].RowList[J]);
        Offset := 0;
        for I := 0 to DockRow.ColList.Count - 1 do
          with TdxDockCol(DockRow.ColList[I]) do
          begin
            Pos := Point(Offset, Pos.Y);
            Inc(Offset, BarControl.Width);
          end;
      end;
    finally
      EndUpdate;
    end;
  end;
end;