Click here to Skip to main content
16,021,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have combobox and some option like 1,2,3,4 which saves in xml after i select a option.And when i open that xml it should show the respective value in comboxox box which i have selected before i have use a property ansTexT in usercontrol form


C#
public string ansText
{

    get
    {
        return ddlanswer.SelectedText.ToString();
    }
    set
    {
        ddlanswer.SelectedValue = value;
    }

}

and call it on the mainform like this


C#
ucQst.ansText = qst.beef_answer.ToString();

where beef_answer is from xml.It shows value in beef_answer.But does not show value in ansText.Please help urgent
Posted
Updated 10-Sep-13 23:25pm
v2
Comments
[no name] 11-Sep-13 5:26am    
No, I have just checked, and it's not urgent.
ZurdoDev 11-Sep-13 7:30am    
If you want to show the value in ansText then do so, what's the issue?

1 solution

I do not see the complete code you wrote, but I have two ideas to try:

1. Use
C#
return ddlanswer.Text;
in the ptoperty getter. SelectedText means the text portion selected in the "text editor" and not the item selected.

2. Use
C#
ddlanswer.SelectedItem = value;
in the property setter. I guess you initialized the combo box with a set of strings, so you do not have a SelectedValue (that is a specified property of the selected item).
 
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