Das hier ist nur eine Idee... schlagt mich nicht dafür
Delphi-Quellcode:
procedure setPanelHeight(var aPanel: TPanel; var aLabel: TLabel);
var
iDiff: Integer;
begin
iDiff := aLabel.Height - aPanel.Height;
if iDiff > 0 then
aPanel.Height := aPanel.Height + iDiff;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption := 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore';
setPanelHeight(Panel1, Label1);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Label1.Caption := 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.';
setPanelHeight(Panel1, Label1);
end;