Click here to Skip to main content
15,888,022 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi I can not speak good English,I wish I could say good

I have a drop down list in my project(asp.net framework 4 (c#))
I want to remove some value of these drop
The user could select a value from drop to remove it
The values ​​of drop is hierarchically,The parent and child

I do not know how to do
Please help me
Thank you
Posted
Comments
Maciej Los 30-Jun-13 4:37am    
What kind of object it is: ListBox, ComboBox?

1 solution

The documentation for DropDownList says you can use the Remove or RemoveAt methods.

ListItemCollection Class

Remove the currently selected item
lstReservations.Items.RemoveAt(lstReservations.SelectedIndex)


In Visual Studio, you can click the Help menu item, then View Help to access the help file information for each of the .NET Framework Classes. Many of the help file entries have small examples.
 
Share this answer
 
v4
Comments
nazanin6868 30-Jun-13 8:52am    
Thank you
but remove metod remove all value and I want to remove some value that user requset
Mike Meinz 30-Jun-13 9:07am    
I use these two methods. I know what they do!

Remove() removes the item at a specified index - lstReservations.Items(idx).Remove()

RemoveAt() removes the item at the specified index. - lstReservations.Items.RemoveAt(idx)

Public method Remove Removes the specified item from the ComboBox.
Public method RemoveAt Removes an item from the ComboBox at the specified index.
nazanin6868 30-Jun-13 9:19am    
ComboBox and dropdownlist are different?Methods used in these two controls are the same?
How should I use this method?
Mike Meinz 30-Jun-13 9:38am    
DropDownList class has same methods for its ITEMS property. Remove() works a little differently but RemoveAt() works the same.

ListItemCollection Class
nazanin6868 30-Jun-13 9:46am    
ok,Thank you very much

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