本帖最后由 gdxg0762 于 2011-07-08 09:19:53 编辑

解决方案 »

  1.   


     combobox.InsertItemValue(10, 'AAA', 'AAA');用Ccombobox的InsertItemValue方法,
    方法方法参数如下:
    InsertItemValue(Index: Integer; const Item, Value: string)
      

  2.   

    这个方法我试过,不行;
    因为ComboBox1为空时或者combobox的intems不超过10时插入会报错
      

  3.   

    ComboBox1.Items.Insert是插入,向已有的内容里插入
    你内容没有这么多当然会出错,你要盖楼,1楼没盖就盖10楼,你说可以吗
    如果去序号可以用ComboBox1.ItemIndex+1自带的combobox1只有items,而没有values,只能取items和索引,而不能取自定义的序号
    如果要取items和values要使用第三方控件
      

  4.   

    用combobox.addObject( 'aaa', TObject(10) );
    取的时候用combobox.items.Objects[index]
      

  5.   

    需求重新确认下!
    没有10行的时候,插入到第几行!
    add加后面,insert直接插入
      

  6.   


    抱歉,我搞错了,Raize控件RzComboBox才有这个方法
      

  7.   

    先对Ccombobox的items属性进行判断。
      

  8.   

    if ComboBox.Items.Count > 10 then
     insert()
    else
     Add();
      

  9.   

    建议你使用TStringlist,因为 ComboBox.Items就是TStringlist,方法如下
    1、创建MyList:TStringlist
    2、在MyList插入操作
    3、 ComboBox.Items.addstrings(Mylist)
      

  10.   

    你需要预先增加到最大行数的,否则才有2行你插入10肯定报错。要么你就判断如果不到你这个行数你自动补充进去,没别的办法。返回行号简单,ItemIndex + 1就是行号了
      

  11.   

    先根据属性判断ComboBox.Items.Count
      

  12.   

    我取值的时候会报错procedure TForm1.Button1Click(Sender: TObject);
    begin
      ComboBox1.AddItem('afsdf',TObject(10));
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      ComboBox1.Items.Objects[10];
    end;先单击Button1 再单点button2
      

  13.   

    你这个方式我好像也试过不行,也许我不知道怎么用;
    我的测试DEMO如下:procedure TForm1.Button2Click(Sender: TObject);
    var
      MyList:TStringlist;
    begin
      //ComboBox1.Items.Objects[10];
      MyList:=TStringList.Create();
      MyList.Add('fasf');
      MyList.Add('aaa');
      MyList.Add('aa');
      MyList.Insert(10,'fdsafdsa');
      ComboBox1.Items.AddStrings(MyList);
      MyList.Free;
    end;我想达到的目标是:前10行中其中有三行才有数据,但是我又在第10行中添加数据,应该怎么样做的问题;且4-9行为NIL
      

  14.   

    加入空格后,在combobox list中会显示出来啊,我是不想显示;
      

  15.   

    如果 一定要用 combobox 那么看我的文章 已经解决 很好用 没有内存泄露
    http://blog.csdn.net/chinawcs/article/details/6610754还可以用 三方组件解决这个  比如 ehlib中的TDBComboBoxEh     while not Ado.Eof do
        begin
          cbo.Items.Add(Ado.Fields[1].AsString);
          cbo.KeyItems.Add(Ado.Fields[0].AsString);
          Ado.Next;
        end;
      

  16.   

    Integer(combobox.items.Objects[index])
      

  17.   

    另外  RzComboBox 可以这样
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      RzComboBox1.InsertItemValue(0,'aa','bb');
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      ShowMessage(RzComboBox1.Values.Strings[RzComboBox1.itemindex] );
    end;
    方法都有三种了 楼主可以结贴了
      

  18.   

    应该是
    ComboBox1.Items.Insert(9,'AAA');