usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Drawing;usingSystem.Data;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespacedemo{ Public Partial classAutotext:usercontrol {Private string_procvalue; Public stringProcvalue {Get{return_procvalue;} Set{_procvalue =value;} } //Defining Delegates Public Delegate voidAutosrchhandle (Objectsender, EventArgs e); //Defining Events Public EventAutosrchhandle autosearched; PublicAutoText () {InitializeComponent (); Bindlistbox (); } voidBindlistbox () {LBSTATION.ITEMS.ADD ("Anhui"); LBSTATION.ITEMS.ADD ("Beijing"); LBSTATION.ITEMS.ADD ("Chongqing"); LBSTATION.ITEMS.ADD ("Shanghai"); } Private voidTbproc_mouseenter (Objectsender, EventArgs e) {lbstation.visible=true; } Private voidTbproc_keyup (Objectsender, KeyEventArgs e) {TextBox EOBJ= Sender asTextBox;//Event Source Object if(E.keycode = =keys.enter) {Lblmsg.text=Eobj.text; } Else{Procvalue=Tbproc.text; Lblmsg.text=Procvalue; } } Private voidLbstation_mousemove (Objectsender, MouseEventArgs e) {ListBox EOBJ= Sender asListBox; Eobj.selectedindex=Eobj.indexfrompoint (e.location); } }}View Code
customizing automatic search Controls