delphi ComboBox如何添加下拉菜单的。
delphi ComboBox怎么添加下拉菜单的。。rt[解决办法]unit Unit1interfaceusesWindows, Messages, SysUtils,
delphi ComboBox怎么添加下拉菜单的。。
rt
[解决办法]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ComboBox1: TComboBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
combobox1.Items.Add('ABC');
combobox1.Items.Add('cde');
end;
end.
[解决办法]直接在items属性里添加
[解决办法]还有一中:
combobox1.Items.CommaText :='ABC,abc';
就添加了 ABC 和 abc 下拉框
[解决办法] combobox1.Items.CommaText :='AAA,bbb';
添加 AAA 和 bbb 下拉框
[解决办法]1、直接付值:
combobox1.Items.Add('ABC');
combobox1.Items.Add('cde');
2、如果是要从表中读取来绑定:
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select id from table order by id');
ADOQuery1.Open;
if ADOQuery1.RecordCount >0 then
begin
ComboBox1.Items.Clear;
ADOQuery1.First;
while not ADOQuery1.Eof do
begin
ComboBox1.Items.Add(ADOQuery1.fieldbyname('id').AsString) ;
ADOQuery1.Next;
end;
end;