DBCOMBOBOX在窗体创建时为空,用鼠标单击时显示出库中表的数据,DBCOMBOBOX在程序中动态设置关联的数据表、字段,请各位大侠帮我,

解决方案 »

  1.   

    DBComboBox1.DataSource :=datasource1;
    DBComboBox1.DataField :='name';
      

  2.   

    同意 luoweicaisd(笑三少) ,在formcreat事件中給DBComboBox1.DataSource和 DBComboBox1.DataField符值.
      

  3.   

    在窗体创建时,去掉相关属性,
    在OnClick时,再写进去。
      

  4.   

    没有必要用DBCOMBOBOX用ComboBox就行了。
    看看这段代码,
    procedure TfrmBlurred.ComboBox1DropDown(Sender: TObject);//在DropDown事件中触发
    begin  
        Comtext.Clear;
        frmDM.ClientDataSetHistoryList.Close;    //打开数据表
        frmDM.ClientDataSetHistoryList.CommandText:='select FieldType,FieldNum from OtherList_tab where FieldType='+#39+F+'''';
        frmDM.ClientDataSetHistoryList.Open;
        with frmDM.ClientDataSetHistoryList do      
        begin
            First;
            while Not Eof do
            begin
               Comtext.Items.Add(Fields[1].AsString);
               Next;
            end;
        end;
    end;