Delphi组件ADOQuery向combobox添加列表项的例程

var

    myrecord:integer;

myopensql('Select * From cx_consumable');
if datamod.ADOQuery1.Bof and datamod.ADOQuery1.Eof then
   //这里是无记录时进行的操作    
else

    begin
         combobox1.Clear;
         for myrecord:=1 to datamod.ADOQuery1.RecordCount do
              begin
                  combobox1.Items.add(datamod.adoquery1.fieldbyname('number').asstring+' '+datamod.adoquery1.fieldbyname('name').asstring);
                  datamod.ADOQuery1.Next;
              end;
     end ;

你可能感兴趣的:(combobox)