Click here to Skip to main content
15,743,541 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to clear a selected value in combo box without deleting any value in the list.

Not sure what you want to so.
According to my understanding you want to reset dropdown values.
You can use
Share this answer
suganyass 3-Aug-12 0:57am    
Thank u for your reply. But I am using MVVM pattern. I need to clear the selected value in the combo box in View Model. while clear that value, list item get deleted.
Sharma Richa 3-Aug-12 1:02am    
You have to set the selected value property to null or something else you want in your viewmodel
suganyass 3-Aug-12 1:08am    
If i set null means then the selected value clear from list. Then the List loaded without the selected value.
Santhosh Kumar Jayaraman 3-Aug-12 1:10am    
please check solution2
Sharma Richa 3-Aug-12 1:14am    
you have to set it to null when you finished working with combobox selected value.
try this

if in view:
ComboBox1.SelectedIndex = -1 

or dou you want it in viewmodel,

then Have a property for selected item. and set it to null:

For eg:
public List<gender> GenderList

//include notify property changed for that property..the above one is just outline

Then have a property
Public Gender SelectedGender

Bind Itemsource to GenderList property and Selectedvalue property to SelectedGender.

Whenever You want to clear the selection Set SelectedGender =null. SInce Notifyproperty changed element is there, it will clear the selection
Share this answer
suganyass 3-Aug-12 1:15am    
Thank u..... I got the answer.....
Santhosh Kumar Jayaraman 3-Aug-12 1:16am    
ya welcome

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