0
votes

i have a procedure intended to prepare a form with a couple of labels and dropdowns. But i cannot change the font color of the label. Can anybody please assist?

I have found a link that says they found the answer, but i cannot make sense of it. How to programmatically alter Font properties in Firemonkey controls

Below is the code for the unit trying to execute the change.

unit procedures;

interface

Uses
  System.SysUtils, System.Types, System.UITypes, System.Classes,
  System.Variants, fmx.controls;

Procedure resetproductlists;

implementation

uses main_unit, datalive_unit, AddUniqueItemToComboBox;

Procedure resetproductlists;
begin
  With Datalive.products Do
  Begin
    Try
      active := False;
      params.clear;
      sql.text := 'select supplier,item,width,height from products';
      active := True;
      Main.Combobox1.clear;
      Main.Combobox2.clear;
      Main.Combobox3.clear;
      Main.Combobox4.clear;
      Main.Edit1.text := '';
      Main.Edit2.text := '';
      Main.SpinBox1.Value := 0;
      Main.label13.text := 'n/a';
      Main.label13.StyledSettings := Main.label13.StyledSettings -
        [TStyledSetting.ssFontColor];
      Main.label13.FontColor := TAlphaColors.Aqua;
      Main.label14.text := 'R 0.00';
      Main.label14.FontColor := clBlack;
      while not eof do
      Begin
        try
          addtocombo(Main.Combobox1, Fieldbyname('supplier').Asstring);
          addtocombo(Main.Combobox2, Fieldbyname('item').Asstring);
          addtocombo(Main.Combobox3, Fieldbyname('width').Asstring);
          addtocombo(Main.Combobox4, Fieldbyname('height').Asstring);
        finally
          next;
        end;
      End;
    Finally
      active := False;
    End;
  End;
end;

end.

the addtocombo procedure only inserts the text into the combobox (if it is not already found in it.).

Any assistance would be great. Thank you

1
Does this solution help? It helped me. stackoverflow.com/questions/31222353/…Edward

1 Answers

1
votes

Thw following two lines change the font color of a label in XE5:

  Label13.StyledSettings := Label13.StyledSettings - [TStyledSetting.FontColor];
  Label13.TextSettings.FontColor := TAlphaColors.Aqua;

But you already have that code in there. So the question is why it does not work in your case. I'd say that either your code does not execute or something changes the color back to black. Try setting a conditional breakpoint in TTextSettings.SetFontColor at FFontColor := Value; that only fires when changing the color to or from Aqua. This might give you a clue.