Delphi 2009 - create a TPanel at runtime and change its color

后端 未结 2 1746
没有蜡笔的小新
没有蜡笔的小新 2020-12-06 17:18

got a strange problem: I create a TPanele at runtime and change its color - however, the color is still clBtnFace.

Here\' the code:

procedure TForm1.         


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 17:41

    Try this :-)

    procedure TForm1.Button1Click(Sender: TObject);
    var
      pnlTest : TPanel;
    begin
        pnlTest := TPanel.Create(Form1);
        pnlTest.Parent := Form1;
        pnlTest.Width := 100;
        pnlTest.Height := 100;
        pnlTest.ParentBackground := false;
        pnlTest.Color := clRed;
    end;
    

提交回复
热议问题