我想将我创建的其中一个标签的颜色动态更改为红色。但它似乎没有工作。有谁知道如何解决这个问题?
我使用的代码片段:
procedure TForm1.FormCreate(Sender: TObject);
var
H: byte;
begin
//T := Screen.Size.Height;
Label1.Text := 'scherm hoogte is genoegz ';// +IntToStr(T);
Label1.Font.Style := Label1.Font.Style + [TFontStyle.fsBold];
T := Screen.Size.Width;
Label2.Font.Style := Label2.Font.Style + [TFontStyle.fsUnderline];
Label2.Font.Style := Label2.Font.Style + [TFontStyle.fsItalic];
Label2.TextSettings.FontColor := TAlphaColors.Yellowgreen; //$FFFF0000;//clRed; //$FF0000FF;
Label2.Text := 'scherm breedte is ' + IntToStr(T);
for H := 0 to 6 do
begin
DagLabel[H] := TLabel.Create(Self);
with DagLabel[H] do
begin
Parent := Form1;
Position.X := H * (T div 6) + 25;
Position.Y := 50;
Font.Style := [TFontStyle.fsBold];
//TextSettings.FontColor := TAlphaColors.Yellowgreen;//does not work here eighter
case H of
0 : Begin
Text := 'Zondag';
TextSettings.FontColor := TAlphaColors.Red;
end;
1 : Text := 'Maandag';
2 : Text := 'Dinsdag';
3 : Text := 'Woensdag';
4 : Text := 'Donderdag';
5 : Text := 'Vrijdag';
else
Text := 'Zaterdag';
end;
end;
end;
end;
答案 0 :(得分:0)
您是否尝试将新颜色值分配给Font而不是TextSettings?
label2.Font.Color := $00000000