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

后端 未结 2 1745
没有蜡笔的小新
没有蜡笔的小新 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:26

    When you want to have colored panels under a themed OS you have to set ParentBackground to False.

    0 讨论(0)
  • 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;
    
    0 讨论(0)
提交回复
热议问题