Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
How to remove selected items from ListBox when a datasource is assigned to it in C#
Posted

Locate the item in your datasource and then remove it from that datasource.

C#
mySource.RemoveAt(FindItem());
myListBox.DataSource = mySource;
 
Share this answer
 
Comments
Reza Ahmadi 21-Apr-12 5:53am    
5!
Abhinav S 21-Apr-12 6:00am    
Thank you Reza.
 
Share this answer
 
v2
Comments
h7h7h7 21-Apr-12 6:54am    
Thankyou, but I think you are not understanding me listen dear frien. I have to listboxes
ListBox1 that have this data:

CCCC
----
BBBB
----
AAAA
----

and listbox2 that is empety......I just want, when I click in button in listbox2 to have those data sorted without "---------------"....I have code for sortin them, But I don't know how to write code that ok sort data but dont take this string "-------------------".....
Can you be more specifike about that.. I am trying to implement but I cant
So I have listbox with item " listbox1.datasource=datafile" this codo get elements and put them in listbox1, now from this list box that is:
AAAAA
-----
BBBBB
-----

I want to remove those lines "-------"; how is that impposible when datasource is assigned ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900