Joc02
Joc02

Reputation: 345

Delphi XE6 TForm.AutoSize

I've code in Delphi XE2 who work perfectly. But in Delphi XE6 it doesn't work. I create a Tform with the property AutoSize to true. I use a TPanel align alTop with a button for create some another panels.

procedure TForm2.Button1Click(Sender: TObject);
var
   t :TPanel;
begin
   t := TPanel.Create(self);
   t.Parent := self;
   t.Align := alTop;
end;

The form doesn't auto size. If I want to see all my panels I have to move the form (or try to resize, ....).

Have you any idea's ?

Upvotes: 2

Views: 1534

Answers (2)

David Heffernan
David Heffernan

Reputation: 612934

This is indeed a change in behaviour. I can reproduce what you report. Namely that your code results in the form size changing in XE2, but not in XE6.

To work around this you can manually call AdjustSize:

procedure TForm1.Button1Click(Sender: TObject);
var
  Panel: TPanel;
begin
  Panel := TPanel.Create(self);
  Panel.Parent := Self;
  Panel.Top := ClientHeight;
  Panel.Align := alTop;
  AdjustSize;
end;

Upvotes: 3

LHristov
LHristov

Reputation: 1123

Not align, use anchors:

t.Anchors:=[TAnchorKind.akTop];

This is from my XE5 (have no XE6)

Upvotes: 0

Related Questions