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,然后运行; //然后根据自己需要修改;
这样就不会显示内容了;
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,然后运行;
//然后根据自己需要修改;