如何在 Delphi Firemonkey XE7 中更改组合框下拉菜单的字体大小?
How do I change the font size of the drop-down-menu of a combobox in Delphi Firemonkey XE7?
我正在尝试更改 Delphi Firemonkey XE7 中组合框的字体大小。该应用程序将在 Windows 平板电脑上使用。
到目前为止,当 "not opened" 更改字体大小时,组合框中显示的所选项目已经起作用,但是当我单击组合框并打开下拉菜单时,下拉菜单中的项目仍然默认字体大小。有谁知道如何解决这个问题?
目前的源代码:
for i := 0 to combobox1.Count - 1 do
begin
combobox1.ListBox.ListItems[i].TextSettings.Font.Size := 20;
combobox1.ListBox.ListItems[i].StyledSettings := combobox1.ListBox.ListItems[i].StyledSettings - [TStyledSetting.Size];
end;
单击 here 查看所描述问题的图片。
提前致谢!
莉亚
要在 ComboBox 中使用带样式的 ListBox 项目,请设置 ComboBox.DropDownKind := TDropDownKind.Custom
Procedure StyleComboBoxItems(ComboBox:TComboBox; Family:string; Size:Single);
var
Item : TListBoxItem;
i : Integer;
begin
for i := 0 to ComboBox.Count-1 do begin
Item := ComboBox.ListItems[i];
Item.Font.Family := Family; //'Arial';
Item.Font.Size := Size; //20;
// Item.FontColor := TAlphaColorRec.Red;
Item.StyledSettings := Item.StyledSettings - [TStyledSetting.Family,TStyledSetting.Size,TStyledSetting.FontColor];
// Item.Text := '*'+Item.Text;
end;
end;
//call like StyleComboBoxItems(cbbXYZ,'Segoe UI',10.0);
//remember to call it everytime you change the cbb list by clearing, adding, deleting etc.
代码由 JAN BLOMQVIST
我正在尝试更改 Delphi Firemonkey XE7 中组合框的字体大小。该应用程序将在 Windows 平板电脑上使用。 到目前为止,当 "not opened" 更改字体大小时,组合框中显示的所选项目已经起作用,但是当我单击组合框并打开下拉菜单时,下拉菜单中的项目仍然默认字体大小。有谁知道如何解决这个问题?
目前的源代码:
for i := 0 to combobox1.Count - 1 do
begin
combobox1.ListBox.ListItems[i].TextSettings.Font.Size := 20;
combobox1.ListBox.ListItems[i].StyledSettings := combobox1.ListBox.ListItems[i].StyledSettings - [TStyledSetting.Size];
end;
单击 here 查看所描述问题的图片。
提前致谢! 莉亚
要在 ComboBox 中使用带样式的 ListBox 项目,请设置 ComboBox.DropDownKind := TDropDownKind.Custom
Procedure StyleComboBoxItems(ComboBox:TComboBox; Family:string; Size:Single);
var
Item : TListBoxItem;
i : Integer;
begin
for i := 0 to ComboBox.Count-1 do begin
Item := ComboBox.ListItems[i];
Item.Font.Family := Family; //'Arial';
Item.Font.Size := Size; //20;
// Item.FontColor := TAlphaColorRec.Red;
Item.StyledSettings := Item.StyledSettings - [TStyledSetting.Family,TStyledSetting.Size,TStyledSetting.FontColor];
// Item.Text := '*'+Item.Text;
end;
end;
//call like StyleComboBoxItems(cbbXYZ,'Segoe UI',10.0);
//remember to call it everytime you change the cbb list by clearing, adding, deleting etc.
代码由 JAN BLOMQVIST