0

使用 Firemonkey,我有一个 TVertScrollBox,其中包含一个 TPanel,该 TPanel 动态填充了许多以下 TDisplayItem 对象。

问题是 TDisplayItem 的大小不正确,因此各种组件上的文本被叠加等。

我可以通过获取组件的大小并使容器的大小等来解决滚动框可见区域中的项目的问题。我尝试刷新和 application.ProcessMessages 来调整所有内容的大小以及各种对齐和扭曲选项,但无济于事。

希望我错过了其中的一个关键因素,并且没有发现 Firemonkey 的限制!

干杯,

马丁。

Constructor TDisplayItem.Create(owner : TComponent);
begin
  inherited Create(owner);
  Align := TAlignLayout.alTop;
  pnlLabels := TPanel.Create(nil);
  pnlLabels.Align := TAlignLayout.alTop;
  pnlLabels.Height := 50;
  pnlLabels.Parent := self;

  lblICAO := TLabel.Create(nil);
  lblICAO.Parent := pnlLabels;
  with lblICAO do
  begin
    text := 'ICAO';
    Height := 30;
    Position.X := 10;
    align := TAlignLayout.alTop;
    TextAlign := TTextAlign.taCenter;
    Font.Size := 18;
    FontColor :=  $FF00D000 ;
    Visible := False;
    StyledSettings := [TStyledSetting.ssFamily];//, TStyledSetting.ssFontColor];
  end;

  lblFrom := TLabel.Create(nil);
  lblFrom.Parent := pnlLabels;
  with lblFrom do
  begin
    text := 'From : ';
    Height := 30;
    Position.X := 10;
    Position.y := 2;
    width := 150;
    FontColor :=  $FFFF0000 ;
    StyledSettings := [TStyledSetting.ssFamily];//, TStyledSetting.ssFontColor];
  end;

  lblTo := TLabel.Create(nil);
      lblTo.Parent := pnlLabels;
  with lblTo do
  begin
    text := 'To : ';
    Height := 30;
    Position.X := 170;
    Position.y := 2;
    width := 150;
    FontColor :=  $FFFF0000 ;
    StyledSettings := [TStyledSetting.ssFamily];//, TStyledSetting.ssFontColor];
  end;



 lblStatus := TLabel.Create(nil);
  lblStatus.Parent := pnlLabels;
  with lblStatus do
  begin
    text := 'Status : ';
    Height := 30;
    Position.X := 330;
    Position.y := 2;
    width := 100;
    Font.Size := 10;
    FontColor :=  $FFFF0000 ;
    StyledSettings := [TStyledSetting.ssFamily];//, TStyledSetting.ssFontColor];
  end;

  lblNonGeog  := TLabel.Create(nil);
  with lblNonGeog do
  begin
    text := 'Non-Geog : ';
    Height := 30;
    Position.X := 440;
    Position.y := 2;
    width := 150;
    Font.Size := 10;
    FontColor :=  $FFFF0000 ;
    StyledSettings := [TStyledSetting.ssFamily];//, TStyledSetting.ssFontColor];
  end;
  lblNonGeog.Parent := pnlLabels;

  memItem := TLabel.Create(nil);
  memItem.Parent := self;
  with memItemE do
  begin
    Align := TAlignLayout.alTop;
    DisableFocusEffect := False;
    AutoSize := True;
    WordWrap := True;
  end;
4

1 回答 1

0

好的,终于解决了。我在正确的路线上认为这是一个绘图问题 - 当其中一个标签的文本被更改时,需要 label.dopaint。这会更新标签的高度,即使它不在显示区域中。然后,父 TPanel 可以通过对子组件的高度求和来正确设置它的高度。

于 2013-04-17T10:31:02.857 回答