在运行时在 Firemonkey 中创建组件

问题描述 投票:0回答:0

我正在使用这段代码在运行时创建一个 TPanel 组件:

begin
   MyPanel := TPanel.Create(Self);
   MyPanel.Name := 'mypanel';
   MyPanel.Position.X := 0;
   MyPanel.Position.Y := 0;
   MyPanel.Width := 100;
   MyPanel.Height := 100;
   Form2.Fill.Kind := TBrushkind.Solid;
   form2.fill.Color := claSlateGrey;
   MyPanel.Visible := True;
end;

但什么也看不见。 所有主要属性(大小和位置)都应该足够了,但似乎还不够。 在其他形式中,我在运行时创建了大量组件,它们运行良好。我想知道是什么让这个案例与其他案例不同。 我做错了什么?

delphi components runtime firemonkey dynamic-class-creation
© www.soinside.com 2019 - 2024. All rights reserved.