第一个combobox有a,b,c第二个combobox有a1,a2,b1,b2,c1c2怎么让第一个combobox选a,第二个combobox显示a1,a2;选b,显示b1,b2,选c,显示c1,c2?

解决方案 »

  1.   

    如果是两个表的话.可以使用dbcombobox实现.
      

  2.   

    不是表,a,b,c,a1都是items.
      

  3.   

    procedure TForm1.ComboBox1Change(Sender: TObject);
    begin
     case combobox1.ItemIndex of
      0:begin
         combobox2.Items.Clear;
         combobox2.Items.Add('a1');
         combobox2.Items.Add('a2');
         combobox2.ItemIndex:=0;
        end;
      1:begin
         combobox2.Items.Clear;
         combobox2.Items.Add('b1');
         combobox2.Items.Add('b2');
         combobox2.ItemIndex:=0;
        end;
     end;
    end;
    不知道是不是你想要的。
      

  4.   

    保留一份combobox2的items的副本,combobox1变化时,遍历items的副本,然后用Pos判断其中是否包含'a',包含的插入到combobox2中
      

  5.   

    原来要用 add函数 我用了 赋值了~