c# - Textbox Auto Complete - Winform + LINQ -
i'm building simple win form application 1 datagrid, 1 textbox. have 10k records of names.
what want implement sort of auto complete feature when user types textbox, datagrid updated display matches accordingly.
just test out, have 1 datacontext object returns names table , put code in textbox1_textchanged event reset data source
this.datagrid1.datasource = (from p in connectionwrapper.getconnectionobj.patientsnormalizeds p.name.contains(textbox1.text) select p).take(30);
this works fine on local connection when pulling data off remote sql server of course slow, typing becomes sluggish , unacceptable users.
just wondering if can done out changing design. can of course load entire table list or datatable @ form_loading , run search against cause form stop responding 3 seconds or so...
this simple developers i'm new.
thanks!
a couple of approaches spring mind. first involve not filtering on every key press rather searching when user has paused, i.e. think they've typed enough , want see returns. done using timer delay reset every key press.
using background thread run query leaves interface responsive while data retrieved.
i'd @ returning minimum object linq, i.e. p.name rather whole p object. speed data transmission , responsiveness.
Comments
Post a Comment