Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

tlmddock horizontal split: How to set 2 panels to the same width?

This code creates 2 panels with horizontal split:

procedure TForm1.Button1Click(Sender: TObject);
var
  pnl: TLMDDockPanel;
begin
  pnl := TLMDDockPanel.Create(Self);
  pnl.Caption := 'My panel 1';
  LMDDockSite1.DockControl(pnl, LMDDockSite1.SpaceZone, alClient);

  pnl := TLMDDockPanel.Create(Self);
  pnl.Caption := 'My panel 2';
  LMDDockSite1.DockControl(pnl, LMDDockSite1.SpaceZone, alDocRight);
end;

But the right aligned panel has very small width. How to set both panels to the same width so that the splitter exactly tiles both panels to equal width?
Tagged:

Comments

  • 4 Comments sorted by Votes Date Added
  • After docking you can use Panel.Zone.Width to change panel's zone width. You probably will need to set the width of only one of two zones, another one will be resized accordingly.
  • Alternatively you can use LMDDockSite1.SpaceZone.SetChildrenSizes(...) method.
  • Panel.Zone.Width does not change anything.

    But your second answer 'SetChildrenSizes' does the job as desired:

    procedure TForm1.Button1Click(Sender: TObject);
    var
      pnl: TLMDDockPanel;
      nWidth: Integer;
    begin
      pnl := TLMDDockPanel.Create(Self);
      pnl.Caption := 'My panel 1';
      LMDDockSite1.DockControl(pnl, LMDDockSite1.SpaceZone, alClient);

      pnl := TLMDDockPanel.Create(Self);
      pnl.Caption := 'My panel 2';
      LMDDockSite1.DockControl(pnl, LMDDockSite1.SpaceZone, alDocRight);

      nWidth:= ceil(LMDDockSite1.SpaceZone.Width / 2);

      LMDDockSite1.SpaceZone.SetChildrenSizes([nWidth, nWidth]);
    end;

    Many thanks!!!
  • Just for note: Panel.Zone.Width (as well as Height) works for some panel alignments only. For alDocRight (you second panel) it should work.

Sign In or Register to comment.