c# - ListBox DataSource assignment -


i have here desktop application listbox accept records (files inside directory , sub-directories) of more 10,000. when assign datasource datatable of more maybe 50,000 makes ui hang though inside dowork of backgroundworker, thus, hangs progressbar indicates progress of assignment of data in listbox.

i have used method here avoid cross threading while assigning displaymember , valuemember still gets hang.

here's code:

private void bgworkerforlstbox1_dowork(object sender, doworkeventargs e) {     string viewpath = string.empty;      if (radfullpath.checked)         viewpath = "fullpath";     else if (radshortpath.checked)         viewpath = "truncatedpath";     else         viewpath = "filename";      if (dt1 != null)         if (dt1.rows.count > 0)             setlistbox1props(viewpath, "fullpath"); }  delegate void setlistbox1propscallback(string displaymember, string valuemember);  private void setlistbox1props(string displaymember, string valuemember) {     if (this.lstbox1.invokerequired)     {         setlistbox1propscallback d = new setlistbox1propscallback(setlistbox1props);         this.invoke(d, new object[] { displaymember, valuemember });     }     else     {         this.lstbox1.datasource = dt1;         this.lstbox1.displaymember = displaymember;         this.lstbox1.valuemember = valuemember;     } } 

the number of items want show large windows. if need , don't want implement sort of pagination, suggest use listview control in virtualmode. see link more information: http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.virtualmode.aspx


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -