Click here to Skip to main content
15,884,998 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello i WPF App that is linked with combobox items in code-behind page C#.
eg. 0. Extra Control
1. Home
2. Logout
3. Exit
and set combobox.SelectedIndex = 0; so that first item will always be selected.
but i have a issued that when i select combobox value in it repeats itself on selection changed event.
Eg. When i select combobox it represent as

Extra Control //Value displayed in combobox
Extra Control // value displayed in dropdownlist
Home
Logout
Exit

Extra Control value should not display in dropdownlist because it it already displaying in combobox.
how i can solve this ?
Posted
Updated 23-Sep-14 18:21pm
v2
Comments
[no name] 23-Sep-14 12:02pm    
You would solve this by fixing your code. Since we cannot see your code it's pretty much impossible to answer you.
Tarun Jaiswal 23-Sep-14 12:17pm    
I m just simply populating items in combobox at Window_Loaded event
private void Populatecombo()
{
cbProIcon.Items.Add("Extra Controls");
cbProIcon.Items.Add("Home");
cbProIcon.Items.Add("LogOut");
cbProIcon.Items.Add("Exit");
cbProIcon.Items.Add("Sleep");
cbProIcon.Items.Add("Shutdown");
cbProIcon.Items.Add("Restart");
cbProIcon.Items.Add("Lock");
cbProIcon.Items.Add("Logg Off");
cbProIcon.Items.Add("Hibernate");
cbProIcon.SelectedIndex = 0;
}

then on SelectionChanged event m providing some logic

if (cbProIcon.SelectedIndex == 1)
{
//Home
txtcheck.Text += "Home Button Now Clicked now.";
cbProIcon.SelectedIndex = 0;// m setting Index 0 so that Extra Control should always selected.
}
else if (cbProIcon.SelectedIndex == 2)
{
//LogOut
this.Close();
welcome.Show();
}

& so on
but on window when i select combobox it display like this
https://www.dropbox.com/s/azkclhuosm3u45t/combobox.jpg?dl=0

i want to display Extra Control to be display once.
Sergey Alexandrovich Kryukov 23-Sep-14 17:27pm    
There is no "Mumbai" in your code sample. It should be consistent with your issue report, if you want your question to be considered. Also, move it to the question, using "Improve question".
—SA
Sergey Alexandrovich Kryukov 23-Sep-14 17:28pm    
Sorry, probably I accidentally removed your comment "So either remove it from your combobox items or set the SelectedValue to an empty string."
...
—SA
Tarun Jaiswal 24-Sep-14 0:17am    
yeah -SA
actually in combobox what ever value i place in it. it show that value twice
in the case of reply i have posted the source code according to that Extra Control is displayed twice first in combobox when i select it & second in dropdownlist.
so how i can remove/hide the Extra Control value which is displayed in dropdownlist,but not in combobox where user select the combobox


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