using System; using System.Collections.Generic; using System.Text;
namespace winform1 { public class OurComBox : System.Windows.Forms.ComboBox { //==============overwrite ComboBox OnkeyUp method protected override void OnKeyUp(System.Windows.Forms.KeyEventArgs e) { foreach (object item in this.Items) { string[] strs = item.ToString().Split("-".ToCharArray());//利用空格来分格字符串 if (strs[0].Trim().Equals(this.Text))//如果输入的值等于前面的编号 { this.SelectedItem = item; this.SelectAll(); } } base.OnKeyUp(e); } //================= } } |