I was trying to change the color of my label. The code does not show any error, but it does not seem to work either.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Label1: TLabel;
procedure FormCreate(Sender:Tobject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
{TAmpel}
TAmpel = class
private
FAmpel1: string;
public
constructor Create;
procedure schalten();
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
constructor TAmpel.Create;
begin
FAmpel1 := 'TAmpel1';
end;
procedure TAmpel.schalten();
begin
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.Font.Color := clRed;
end;
end.
I tried
Label1.StyleElements := Label1.StyleElements;
but that did not work for me.
It would be nice if somebody could help me... I'm new to lazarus and my teacher does not explain anything
Label1.StyleElements := Label1.StyleElements
? You're re-assigning the value that's already in there. If you're new to programming then consider reading a book/tutorial. And stop tagging questions withDelphi
when they have nothing to do with it.Label1.Font.Color := clRed;
in the form constructor works perfectly ok. What made you think it doesn't work? Did you see the text of the label in some other color than red? Or did you not see any text? If the latter case, perhaps you clearedLabel1.Caption
and forgot to assign a new text? We can't tell as you don't explain any details of the problem.