Delphi 10.3 FMX TCombobox 调整下拉框的宽度
procedure TForm1.ComboboxCalcWidth(Sender: TObject);
var i:Integer;
n,m:single;
begin
m:=40; //初始宽度
for i:=0 to ComboBox1.Items.Count-1 do
begin
n:=ComboBox1.Canvas.TextWidth(ComboBox1.Items.Strings[i]);
if n>m then m:=n;
end;
combobox1.ItemWidth:=Round(m+16)+2;
end;