Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i select value from combobox, so its text must be get change na ??
.
it still shows previous value in combobox text.
also when i take selected item.tostring() in a string variable,
it shows empty(i.e "") value or previous value..
.
so i change the event to lost_focus() but it creates more problems..
.
my same code is workin in windows form but not in wpf.

am i going wrong anywhere ?
or there is any other way to get text in wpf ??
Posted
Comments
[no name] 19-Sep-14 9:04am    
How would you expect us to know what you have done wrong when you do not show us the code that demonstrates this problem?
VR Karthikeyan 19-Sep-14 9:46am    
Use Selection Changed event. Show your code to help you better
Madhuri Gamane 20-Sep-14 0:16am    
private void cmbdesignation_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ClearAll();
if (cmbdesignation.SelectedItem != null)
{
Designation = cmbdesignation.Text; // it gives previous value (suppose i select teacher and prev was student, it still showing "Student")
Designation = cmbdesignation.SelectedItem.ToString(); // it gives "System.Windows.Controls.ComboBoxItem: Teacher"

}
}

got The Answer..
.
Designation = ((ComboBoxItem)cmbdesignation.SelectedItem).Content.ToString();


Thanx For Suggetions...
 
Share this answer
 
You will have to do this

((ComboBoxItem)comboboxxid.SelectedItem).Tag.ToString()
 
Share this answer
 
v2
Comments
Madhuri Gamane 20-Sep-14 0:09am    
it gives Error at .Tag
"Object reference not set to an instance of an object."
member33 20-Sep-14 0:12am    
use it in selected index changed event and wrap it around selecteditem != null
Madhuri Gamane 20-Sep-14 0:19am    
in wpf combobox dont has SelectedIndexChange event..
member33 20-Sep-14 0:26am    
http://www.dotnetperls.com/combobox-wpf
refer that link
Madhuri Gamane 20-Sep-14 0:41am    
Thank you..
But i used this one..
Designation = ((ComboBoxItem)cmbdesignation.SelectedItem).Content.ToString();

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