ListBox control

G

Guest

Hi Guys,

I have non-unique values in my ListBox control, so whenever I do something
like
if (myList.SelectedIndex == 2) I get wrong results, as it picks out the
wrong index. How can I ammend this problem, so that I get the selected index,
i.e. the exact index selected.

Thanks,

I.A
 
M

Michael Groeger

Irfan,

you can try to use the SelectedValue property if you know the value you have
to compare to. For example if you have a listbox with Red, Green, Blue:

if (myList.SelectedValue == "Red")
// [...]

Hope that helps!

Regards,
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top