Click to See Complete Forum and Search --> : Combo Box Selection Value


KazoWAR
November 12th, 2009, 07:27 PM
Is there a way to read the current value of a combo box.

I tried using i = (int)cmb -> SelectedValue; but it is giving me a runtime error.

Example:
Lets say I have a combo box with 5 items. they are a list of numbers spelled out. When one of them is selected, say Three, I want an int to be assigned the current value that is selected. Since Three is the 3rd item in the list then the int variable should be 3, or 2 if the first item is treated as value 0.

BobS0327
December 5th, 2009, 01:21 PM
Try...

int i = cmb->SelectedIndex;

string equivalent would be...

cmb->SelectedIndex.ToString();