GET COMBOBOX SET VALUE AS STRING

Samuel Fernandes

Total Post:159

Points:1117
Posted by  Samuel Fernandes
C# 
C#
 1396  View(s)
Ratings:
Rate this:

Found several ways to do so, but none of them works for me.. I have a combobox with variable number of options (taken from dynamic xml file). For next, I need to know what the user choosed, and I cant find out how to do it. This is one of ways I found and tried:

string myString = myCombobox.SelectedValue.ToString();

At least I dont get an error, but when I try to show that string, it does nothing.

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: Get combobox set value as string

    Hi Samuel,


    Try this:

    string myString = ((ComboBoxItem)myCombobox.SelectedItem).Content.ToString();

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!