如题,急需,combobox,dbcombobox,lookupcombobox都可以,我都用过,没有成功过,那位大佬有好的方法?

解决方案 »

  1.   

    if FieldComboBox.Items.Count<>0 then
        FieldComboBox.Items.Clear;
      FEyeDataSet:=ADataSet;
      for I:=0 to FEyeDataSet.FieldCount-1 do
         FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I];
      with FEyeDataSet do
        begin
        for I:=0 to FEyeDataSet.FieldCount -1 do
          begin
            if not Fields[I].Visible    then Continue;
            if not CanFilter(Fields[I]) then Continue;
            FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);
          end;
        end;
      FFilterStr:='';
      

  2.   

    if FieldComboBox.Items.Count<>0 then
        FieldComboBox.Items.Clear;
      FEyeDataSet:=ADataSet;
      for I:=0 to FEyeDataSet.FieldCount-1 do
         FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I];
      with FEyeDataSet do
        begin
        for I:=0 to FEyeDataSet.FieldCount -1 do
          begin
            if not Fields[I].Visible    then Continue;
            if not CanFilter(Fields[I]) then Continue;
            FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);
          end;
        end;
      FFilterStr:='';
      

  3.   

    if FieldComboBox.Items.Count<>0 then
        FieldComboBox.Items.Clear;
      FEyeDataSet:=ADataSet;
      for I:=0 to FEyeDataSet.FieldCount-1 do
         FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I];
      with FEyeDataSet do
        begin
        for I:=0 to FEyeDataSet.FieldCount -1 do
          begin
            if not Fields[I].Visible    then Continue;
            if not CanFilter(Fields[I]) then Continue;
            FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);
          end;
        end;
      FFilterStr:='';
      

  4.   

    你把问题说清楚点
    我理解的是你想:
    将某个字段的值读取出来作为combobox的item吗?
    这个肯定很好实现啊 稍微懂点vcl与数据库都可以实现 
      

  5.   

    if ADOQuery6.Active=true then ADOQuery6.Close;
        ADOQuery6.SQL.clear;
        ADOQuery6.sql.add('select * from tab_kmmc order by c1');
        adoquery6.open;
        ComboBox1.Items.Clear;
        if ADOQuery6.RecordCount>0 then
        begin
          for i:=1 to ADOQuery6.RecordCount do
          begin
            ADOQuery6.RecNo:=i;
            ComboBox1.Items.Append(adoquery6.findfield('c1').asstring);
          end;
        end
      

  6.   

    我用的是socket连接的,用clientdataset,我是要从一个表中取出某些记录的同一个字段的值作为combobox的items,
      

  7.   

    procedure TQueryBilForm.SetEyeDataSet(ADataSet: TClientDataSet);
    var
      I:Integer;
    begin
      if FieldComboBox.Items.Count<>0 then
        FieldComboBox.Items.Clear;
      FEyeDataSet:=ADataSet;
      for I:=0 to FEyeDataSet.FieldCount-1 do
         FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I];
      with FEyeDataSet do
        begin
        for I:=0 to FEyeDataSet.FieldCount -1 do
          begin
            if not Fields[I].Visible    then Continue;
            if not CanFilter(Fields[I]) then Continue;
            FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);
          end;
        end;
      FFilterStr:='';
    end;
      

  8.   

    FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);
    是关键!
      

  9.   

    昨天晚上我回复这贴子,怎么也回复不了,csdn 老出问题!
      

  10.   

    snake_eye(★蛇眼★上帝派来灌水的人): 可不可以注释一下?^-^
      

  11.   

    读进去:
      FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);要用的时候:
    var
     CurField:TField;
     CurField:=TField(FieldComboBox.Items.Objects[FieldComboBox.ItemIndex]);这下知道了吧!
      

  12.   

    为什么不用DBLOOKUPCOMBOBOX呢
    DBLOOKUPCOMBOBOX.keyvalue=query1.fieldbyname('field').asstring