combo box 控件应该有这样的功能吧?就是指定显示其中的某一条内容。
    我找了好久没找见,而且我的combo在添加项目的时候也是没有办法指定后面的index的,这样子的话可以做到我要的功能吗?
    谢谢!

解决方案 »

  1.   

    Combo1.additem "firt"
    Combo1.additem "second"
    Combo1.additem "third"如果要选中第二项,有两种办法:
    first:
    Combo1.Text= "second"
    second:
    Combo1.ListIndex=1
      

  2.   

    修改ComboBox的Style属性,会有你需要的效果。
      

  3.   

    'ComDlLx4.AddItem ""
    'ComDlLx4.ItemData(ComSsL3.NewIndex) = 0
    'ComDlLx4.ListIndex = ComDlLx4.ListCount - 1
      

  4.   

    谢谢各位。
    我前两天没说太清楚,我要做到的是这样一个效果,
        我在additem语句中无法指定后面的数字,  
        我需要在程序中指定它要显示的内容,也就是说我需要执行象Combo1.Text= "second"这样的命令,所以style只能设置成0-dropdown
        第三点,style设置成0-dropdown的时候用户可以修改里面显示的内容,而我又不希望如此
    怎么办?
      

  5.   

    style设置成2-dropdownlist
    这样它不就不能改了吗?
      

  6.   

    我明白你的意思,我在寫數據庫時也碰到過這個問題。
    當style=dropdownlist時,讀數據庫中的內容到combox中時候,如果用text屬性會出現問題,因為此時,text屬性是只讀的,但我們可以用它的索引值來改變TEXT。
    public function getindex(byval strval as string,byval cbo as combobox) as integer
      for i=0 to cbo.listcount-1
        if trim(cbo.list(i))=trim(strval) then
           getindex=i
           goto exitsub
        end if 
      next
      getindex=-1
    exitsub:
        exit function
    end function
     然後這樣引用:
     combobox1.listindex=getindex(strval,combobox1) 
      

  7.   

    谢谢各位的帮忙,以及fanhongbin(旅行者) 的答案。