请教:combobox绑定数据库表以后,默认显示的是第一条记录,我现在想让它留空;该使用那个属性?
另外:我想让combox有自动完成的功能,输入item的第一个字母后,下拉框就显示所有与这个字母对应的所有item,供用户选择,讨教做过这方面的朋友,谢谢!

解决方案 »

  1.   

    combobox绑定数据库表以后, 再向combobox 中添加一条空串列表项
      

  2.   

    combobox.Text = ""你可以在触发键盘按键后作出判断, 在表中字段查出以combobox.Text 开头的值。
      

  3.   

    1.最好方法:将combobox的DropDownStyle设置为DropDownList
             这样就不会显示内容了;
    2.在comboBox1_KeyUp事件中做处理;
    private void comboBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
    {
    string searchstr="";
    searchstr = searchstr + Convert.ToChar(e.KeyCode);
    // If the Search string is greater than 1 then use custom logic
    if (searchstr.Length > 1)
    {
    int index;
    // Search the Item that matches the string typed
    index=comboBox1.FindString(searchstr);
    // Select the Item in the Combo
    comboBox1.SelectedIndex=index;
    }
    }//你可以参照以上代码,要看效果可以将combobox的DropDownStyle设置为Simple,然后运行;
    //然后根据自己需要修改;