在combobox1的onchange事件中进行查询,查询出符合条件的sheet2,然后写入到combobox2
combobox2处理的方式一样

解决方案 »

  1.   

    也就是在onchange事件里处理就可以了
      

  2.   

    现在的问题就是怎么样才能把sheet1和sheet2中符合条件的加进去?
    combobox.items.add(?????????)
    add里边的怎么写?
      

  3.   

    我来告诉你啊
    with query1 do 
    begin
      close;
      sql.clear;
    sql.add('select * from sheet1');
    open;
     while not eof do 
      begin
        combobox1.item.add( fields[1].asstring);
      next;
      end;
    end ;
    在combobox1.onchanged事件中
      with query1 do 
       begin
         close;
          sql.clear;
           sql.add('select * from sheet2 where field1=:d');
        parambyname('d').asstring:=combobox1.text;
          open;
            while not eof do 
              begin
                 combobox2.item.add(fields[1].asstring);
               next;
               end;
    end;
      

  4.   

    在combox2的OnEnter中写程序,判断combox1的值。
      

  5.   

    fromshow 中加入:
     query1.close;
     query1.sql.clear;
     query1.sql.add('select distinct 仓库名 from sheet1');
     query1.open;
     query1.first;
     combobox1.items.clear;
    while not query1.eof do
     begin
     combobox1.items.add(query1.fieldvalues['仓库名']);
     query1.next;
    end; 
    同理可的:
    combobox1的onchange中加入相应代码
      

  6.   

    同意楼上的!需要用到QUERY组件,在combobox1的onchange中处理。
      

  7.   

    设置表的主从关系,COMBOBOX用成DBCOMBOBOX
      

  8.   

    with query do
    begin
    while not eof do
    begin
      combobox.items.add(fieldbyname('xxx').asstring);
      next;
    end;
    end;
      

  9.   

    在onchanged事件中
    在开始
    应加上combobox2.items.clear;
    这样就行啊,
    如果用代码的话,你就在改改就行啊
    item应为items
      

  10.   

    你要做的是数据库的查询操作!操作完毕后吧查找道的字段添加到combobox中!你主要做的是数据库查询而不是操作combobox!
    对于combobox1的内容你在窗体show中添如记录
     with query5 do
      begin
        Close;
        with SQL do
          begin
            Clear;      
            Add('select * from db12,db1t');
          end;
        Open;
      end;
      for i:=1 to query5.recordcount do
      begin
       combobox1.Items.Add(query5.fieldbyname('仓库名').asstring);
       query5.next;
       end;
    对于combobox2的添加
    procedure TForm1.ComboBox1Change(Sender: TObject);
    begin
    {内容自己写吧!}
    end;