Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to delete an item that is in the checkedlistbox whose value is stored in a variable. but when i tired it didnt ork this is the code i used:

Object rm_no = roomsreserved[j].Trim();
rooms_checkedListBox.Items.Remove(rm_no);

What is the problem this code... I'll be waiting for your help. Thanks in advance.
Posted

rm_no is most likely not the same object as the one you have in the list box.
Thus the object you are trying to remove is not present in the listbox item set.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 15-Aug-11 0:04am    
Good point, my 5.
--SA
Abhinav S 15-Aug-11 0:20am    
Thank you SA.
Take a look at your CheckedListBox.Items collection:

Think about what it means that this a collection of objects.

Examine the methods exposed by this collection: which two of the methods will remove an Item, and what do they require as arguments in order to remove a specific item ?

Yeah, it's probably a bit puzzling: how do you take something like a string, and make it usable as an 'object' : figure that out and you have your answer.

How do you convert any type of .NET object to another type ? Clearly understand that and you will have answered at least 1000 questions you will face in the future ... or, your money back :)

good luck, Bill
 
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