Firemonkey TComboBox 下拉菜单字型修改方法 (D10)

在 FMX 下的 TComboBox 下拉菜单字型修改有二种方法:

  1. uses FMX.Pickers;
  2. 使用 Style,需先设定好 Style 后,再指定预设项的 Style,方法如下:
    procedure TForm1.FormCreate(Sender: TObject);
    var i: Integer;
    begin
         ComboBox2.DropDownKind := TDropDownKind.Custom;
         Combobox2.ListBox.DefaultItemStyles.ItemStyle := 'listboxitemstyle1';
    end;

  3. 使用代码修改字型,方法如下:
    procedure TForm1.FormCreate(Sender: TObject);
    var i: Integer;
    begin
         ComboBox1.DropDownKind := TDropDownKind.Custom;
    
         for i:=0 to ComboBox1.Count - 1 do
         begin
              ComboBox1.ListBox.ListItems[i].StyledSettings :=  ComboBox1.ListBox.ListItems[i].StyledSettings - [TStyledSetting.Family, TStyledSetting.Size, TStyledSetting.FontColor];
              ComboBox1.ListBox.ListItems[i].TextSettings.Font.Size := 20;
              case i mod 3 of
                   0: ComboBox1.ListBox.ListItems[i].TextSettings.FontColor := claRed;
                   1: ComboBox1.ListBox.ListItems[i].TextSettings.FontColor := claBlue;
                   2: ComboBox1.ListBox.ListItems[i].TextSettings.FontColor := claGreen;
              end;
              ComboBox1.ListBox.ListItems[i].TextSettings.Font.Family := '字型名称';
              ComboBox1.ListBox.ListItems[i].Height := 30;
         end;
    end;

     

效果示例:


 

posted @ 2016-01-07 05:38  龟山Aone  阅读(2513)  评论(0编辑  收藏  举报