0

I want to get the value of the selected item of the combobox. I'm using wpf and c#.

I make something like that:

 String c = Combobox.SelectedItem.Tag

No, all the answers are wrong here, but perhaps it is also a bit 'my fault because I could not express myself well. However, for each item in the ComboBox associate a value, for example:

Item1 (Value) => Home (Tag)<br>
Item2 (Value) => Away (Tag)<br>
Item3 (Value) => Half (Tag)<br>


and this is September Tag like:

Now I want get this tag When the related item is selected, for example: user select Item1 and in the variable is valorize Home with tags ... But isn't working. So what is the way to get it?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Harold Finch
  • 576
  • 11
  • 32

2 Answers2

0

You can do this:

string c = comboBox1.SelectedValue != null ? comboBox1.SelectedValue.ToString() : string.Empty;
Christian Amado
  • 946
  • 1
  • 7
  • 31
0
String c=combobox.SelectedValue
David Maisuradze
  • 824
  • 2
  • 12
  • 27