archer_coal Posted October 9, 2003 Posted October 9, 2003 I'm having trouble with a databound listbox In the help files for vb.net it says to just bind the listbox again after new data has been Inserted. This produces Duplicates in the listbox. How do i clear the databox before i re-bind it? listbox1.Datasource.Clear() does nothing or so it seems. Simpley put, i want to empty the listbox then rebind it. Quote
*Experts* mutant Posted October 9, 2003 *Experts* Posted October 9, 2003 To clear a list box of all items use this: ListBox1.Items.Clear() This will remove all items from it. Quote
archer_coal Posted October 9, 2003 Author Posted October 9, 2003 "Error: Can't modify the Items collection when the DataSource property is set." I need some method of discarding the existing datasource before i can edit the listbox items. Quote
*Experts* mutant Posted October 9, 2003 *Experts* Posted October 9, 2003 Oh, sorry I misread a part of your post (I dont know why :)). You would first need to eliminate the DataSource, by setting it to Nothing. Quote
archer_coal Posted October 9, 2003 Author Posted October 9, 2003 Ok i set the datasource to nothing But somthing still isnt right. Listbox2.Datasource = Nothing Listbox2.Items.Clear() '<-- does nothing now Listbox2.Items.Add("test string")' <-- does not appear in the listbox Quote
archer_coal Posted October 9, 2003 Author Posted October 9, 2003 it works It does work. I had multiple bindings my bad. Thanks a lot for your help Mutant Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.