不知道AutoComplete是什么作用的,AutoPostBack是你需要的吗?

解决方案 »

  1.   

    AutoComplete就是只要输入第一个字,如果列表中有第一个字和它相同的项,那么该项就自动显示出来,不用选择,也不用全部输入,没人知道吗
      

  2.   

    AutoComplete Combo Box
    By Mike Chroman
    The following code shows how one can autocomplete a combo box in c#. USAGE: IN THE KEYUP Event of the Combobox on the form just place this code in it private void ComboBox1_KeyUp(Object sender,System.Windows.Forms.KeyEventArgs e) 
    }AutoCompleteCombo(ComboBox1,e);
    }
    public static void AutoCompleteCombo(ComboBox cbo,KeyEventArgs e){String sTypedText;Int32 iFoundIndex;Object oFoundItem;String sFoundText ;String sAppendText ;//'Allow select keys without Autocompletingswitch (e.KeyCode){case Keys.Back:break;case Keys.Left:break;case Keys.Right:break;case Keys.Tab:break;case Keys.Up:break;case Keys.Delete:break;case Keys.Down:break;}//'Get the Typed Text and Find it in the listsTypedText = cbo.Text;iFoundIndex = cbo.FindString(sTypedText);//'If we found the Typed Text in the list then Autocompleteif (iFoundIndex >= 0){ //'Get the Item from the list (Return Type depends if Datasource was bound //' or List Created)oFoundItem = cbo.Items[iFoundIndex];//'Use the ListControl.GetItemText to resolve the Name in case the Combo //' was Data boundsFoundText = cbo.GetItemText(oFoundItem);//'Append then found text to the typed text to preserve casesAppendText = sFoundText.Substring(sTypedText.Length);cbo.Text = sTypedText.ToString() + sAppendText.ToString();//'Select the Appended Textcbo.SelectionStart = sTypedText.Length;cbo.SelectionLength = sAppendText.Length;}}