我的combobox是csDropDownList,好象这样的就不用cmobobox.text直接赋值:
假设:
我的combobox中有内容如{'aa','bb','cc'}
我现在要把'bb'赋给这个组合框
我现在用的方法是:
for lncount:=0 to combobox.Items.Count-1 do
    if combobox.Items[lncount]='bb' then
       break;
    combobox.itemindex:=lncount;请问,有简单一点的方法吗?

解决方案 »

  1.   

    我没有更好的方法了
    不过这样的话 如果是for lncount:=0 to combobox.Items.Count-1 do
        if combobox.Items[lncount]='dd' then
           break;
        combobox.itemindex:=lncount;如果是这种情况 不知道会不会出错
      

  2.   

    for lncount:=0 to combobox.Items.Count-1 do
        if combobox.Items[lncount]='dd' then
        begin
           combobox.itemindex:=lncount;
           break;
        end;
      

  3.   

    为什么可能出错,就算没找到,lncount也会等于combobox.Items.Count-1呀?
      

  4.   

    ComboBox1.Text:=ComboBox1.Items.Strings[ComboBox1.Items.IndexOf('bb')];
      

  5.   

    jinkang(力量):
       也不行
      

  6.   

    有!很简单!!
    combobox.itemindex:=combobox.Items.IndexOf('bb');
      

  7.   

    呵呵,Ailu2002(随风) 的可以了,谢谢:)