如何在程序中删除ComboBox内容?

解决方案 »

  1.   

    combobox1.items.clear;//全部删除
    combobox1.items.delete(i);//删除一条
      

  2.   

    //清空
    combobox1.items.clear;
    //删除指定的值str
    for I:=0 to combobox1.items.count-1 do
    begin
        if combobox1.items[i].text=str then
        begin
            combobox1.items.delete[I];
            break;
        end;
    end;
      

  3.   

    if  combobox1.items[i].text=str  then  这句不行
      

  4.   

    得这么写:
    if combobox1.items.strings[i] = str then ...
      

  5.   

    combobox1.items.delete[I];这句也不行。谢谢师兄
      

  6.   

    combobox1.items.delete(i);//看清楚了,是圆括号
      

  7.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      i:integer;
    begin
      for i:=0 to combobox1.Items.Count-1 do
        begin
          if combobox1.Items[i]='aaa' then
            combobox1.Items.Delete(i);
        end;
    end;剛試過了,不行你砍我:)