listbox1.items.add(combobox1.items.text)

解决方案 »

  1.   

    procedure TForm1.Button4Click(Sender: TObject);
    var
      i : integer;
    begin
      for i := 0 to combobox1.Items.Count - 1 do
      begin
        if listbox1.Items.IndexOf(combobox1.Items.Strings[i]) = -1 then //关键是这句
          listbox1.Items.Add(combobox1.Items.Strings[i]);
      end;
    end;
      

  2.   

    怎么选一个,全部都加进去了?procedure TForm1.ComboBox1Change(Sender: TObject);
    var
      i : integer;
    begin
      for i := 0 to (combobox1.Items.Count - 1) do
      begin
        if listbox1.Items.IndexOf(combobox1.Items.Strings[i]) = -1 then //关键是这句
          listbox1.Items.Add(combobox1.Items.Strings[i]);
      end;
    end;end.
    怎么选一个,全部都加进去了?
      

  3.   

    procedure TForm1.ComboBox1Select(Sender: TObject);
    var I:integer;
        Exist:Boolean;
    begin
        Exist:=False;
        for I:=1 to ListBox1.Items.Count do
        begin
            if ListBox1.Items[I-1] = ComboBox1.Text then Exist:=True;
        end;
        if not Exist then
        begin
            ListBox1.Items.Add(Combobox1.Text);
        end;
    end;
      

  4.   

    分不够再加哈,怎么我在combobox1 中输入字段内容时,每输入一个字符它都向listbox1加上去了?
    我只想加入的是combobox1中有的内容