1
votes

I have ComboBox with а few items. Default returned type of item's value - String. I would like to know how can I get 'Int' type of value of selected item in ComboBox.

Explicit conversion produces an error: Specified cast is not valid.

Thanks!:)

1

1 Answers

1
votes

You can use int.Parse(box.SelectedValue). If it gives you an error, it means that the value is not an integer. In that case, it may be that the value is empty, and only the text is set.