告诉你一段VB程序,虽然我不懂Delphi,但原理应该一样
先生成一个应选记录集(RecordSet),再一条条加入到COMBOBOX中去,用什么数组,脱裤放屁.^_^
Sub CBO_Creat(ComBoBox As ComBoBox, SQL As String)
Dim RS As New Recordset
'    ' Debug.Print SQL
    Set RS = adoPJTX.Execute(SQL, , adCmdText)
    ComBoBox.Clear
    With ComBoBox
        Select Case .Name
        Case "cboGW"
            .AddItem ""
        Case Else
        End Select
    End With
    
    With RS
        While Not RS.EOF
            ComBoBox.AddItem .Fields(1)
            ComBoBox.ItemData(ComBoBox.NewIndex) = CInt(.Fields(0))
            .MoveNext
        Wend
    End With
    If RS.RecordCount < 1 Then ComBoBox.AddItem " "
    SQL = ""
    Set RS = Nothing
End Sub

解决方案 »

  1.   

    可以写个过程,如下:
    procedure toComboBox;
    var
      Query1:TQuery;
    begin
      Query1:=TQuery.Create(Application);
      //Query1的数据库连接设置
      ......
      Query1.SQL.Add('select distinct onation from oldman');
      Query1.Open;
      While not Query1.eof Do
      begin
        ComboBox1.Items.Add(Query1.Fields(0).AsString);
        Query1.Next;
      end;
    end;
      

  2.   

    这样写吗?不懂多问。
    procedure aaa;
    var q1:Tquery;
    begin
      combobox1.items.clear;
      q1:=TQuery.create(application);
      q1.sql.add('select distinct a from db');
      q1.open;
      while not q1.eof do
      begin
        combobox1.items.add(q1.fielddbyname('a').asstring);
        q1.next;
      end;
      q1.close;
    end;