var StringList: TStrings; begin StringList := TStringList.Create; try with StringList do begin Add('This example uses A string List.'); Add('It is the easiest way to add strings'); Add('to a combobox''s list of strings.'); Add('Always remember TStrings.Create method'); Add('is abstract; So use TStringList.Create'); Add('method instead.'); end; with ComboBox1 do begin Width := 210; Items.Assign(StringList); ItemIndex := 0; end; finally StringList.free; end; end;上面的DELPHI帮助中的例子; 如果你需要控制字体的话,你可以把显示这个字符串集的控件的字体设置一下
begin StringList := TStringList.Create;
try
with StringList do begin
Add('This example uses A string List.');
Add('It is the easiest way to add strings');
Add('to a combobox''s list of strings.');
Add('Always remember TStrings.Create method');
Add('is abstract; So use TStringList.Create');
Add('method instead.'); end; with ComboBox1 do begin Width := 210;
Items.Assign(StringList);
ItemIndex := 0;
end;
finally
StringList.free;
end;
end;上面的DELPHI帮助中的例子;
如果你需要控制字体的话,你可以把显示这个字符串集的控件的字体设置一下
跟TStrings本身无关。
你只能使用TStringList这些类。