Visual Basic: How do I get the position number of the selected item in a list box/combo box?
Such as,
Selection a
Selection b
Selection c
Selection d
I pick out option c therefore , the value to become returned ought to be 3 because it is the 3rd index while in the list.
You should please somebody! Do you’ve any ideas
Thanks
Use this SelectedIndex property.
Option c would actually have a SelectedIndex price of ONLY TWO, since they start with 0.
-1 shows no product selected.
While MY SPOUSE AND I do agree with the fact that SelectedIndex is a way to tell everyone position, you must really change you pattern.When a person fill some sort of combobox, you should be using some type of dataset.That dataset must have labels and also values.Such as, a set of users and also their userIDs.Then you would employ a list including
33 Karl
TWENTY THREE Jenny
72 Mike
64 Peter
You should only show the names from the combobox and when the person selects you, you can ask exactly what the SelectedValue is that this is useful to match data from a SQL DB or perhaps have powerful data while in the combobox.
Leave a Reply
You must be logged in to post a comment.