Jump to content
JimKueneman

Dynamically Created Label Font Change

Recommended Posts

Hi, 

 

Delphi 11.2 Patch 1, FireMonkey app running in Windows 11 in a virtual Machine on OSX.  Does not work compiled into Linux or OSX either.

 

procedure TForm1.Button4Click(Sender: TObject);
var
  L: TLabel;
begin
  Label1.TextSettings.Font.Style := [TFontStyle.fsBold];  // Desiger Dropped Label is Bold
  L := TLabel.Create(Self);
  L.Text := 'Testing';
  L.Align := TAlignLayout.Bottom;
  L.TextSettings.Font.Style := [TFontStyle.fsBold];  // Dynamically created Label is not Bold
  L.Parent := Layout1;
end;

Why won't the dynamically added Label respond to changing TextSettings.Font.Style?

 

Jim

Edited by JimKueneman

Share this post


Link to post

Most probably you've changed the Label1.StyledSettings property. I've tried with the default settings of the TLabel you cannot change the style from the code.

 

In order to work you have to add:

L.StyledSettings:=L.StyledSettings-[TStyledSetting.Style];

 

 

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×