1

I've got 5 labels on my form whose Fonts styles should all get the BOLD property added. I tried doing this using the code below but only Label2 gets bold and the rest still stays as it is at design time.

 Sleep(350); TThread.Synchronize(nil, procedure begin Label2.TextSettings.Font.Style := Label2.TextSettings.Font.Style + [TFontStyle.fsBold]; Label2.TextSettings.FontColor := TAlphaColorRec.Gray; end); Sleep(350); TThread.Synchronize(nil, procedure begin Label3.TextSettings.Font.Style := Label3.TextSettings.Font.Style + [TFontStyle.fsBold]; Label3.TextSettings.FontColor := TAlphaColorRec.Gray; end); Sleep(350); TThread.Synchronize(nil, procedure begin Label4.TextSettings.Font.Style := Label4.TextSettings.Font.Style + [TFontStyle.fsBold]; Label4.TextSettings.FontColor := TAlphaColorRec.Gray; end); Sleep(350); TThread.Synchronize(nil, procedure begin Label5.TextSettings.Font.Style := Label5.TextSettings.Font.Style + [TFontStyle.fsBold]; Label5.TextSettings.FontColor := TAlphaColorRec.Gray; end); Sleep(350); TThread.Synchronize(nil, procedure begin Label6.TextSettings.Font.Style := Label6.TextSettings.Font.Style + [TFontStyle.fsBold]; Label6.TextSettings.FontColor := TAlphaColorRec.Gray; end); Sleep(350); 

The colors change on each Label, but the Fonts aren't getting bold except for the first label which I try to get bold... this is confusing me. please help me. I use Delphi 10.3.3 Community Edition and an Android 10 Smartphone (Lineage 17.1)

3
  • Are you running the code above in an external thread or the main thread? Commented Jan 15, 2021 at 19:06
  • In an external Thread, thats why I synchronized it Commented Jan 15, 2021 at 19:06
  • Good, I just wanted to check! Commented Jan 15, 2021 at 19:09

1 Answer 1

1

For all labels, for which you want to manipulate the Style property, you need to remove the Style setting from StyledSettings.

(As the color change works, you already removed the FontColor setting from StyledSettings)

Actually, if you set any of these settings at design time, the IDE removes the corresponding StyledSetting. If you don't change any of these settings at design time, you must remove the corresponding StyledSettings before you can change the setting at runtime.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks that worked for me. Sthe FontColor property was already false without changing anything, but now as I removed the Style Tag it works :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.