I am trying to get text from an entry in my winForms ListBox by index, but I seem to be stumped. The only logical thing I can think of is:
listBox.Items[index].ToString
But this does not return the desired result.
Does anyone know how to do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What do you have in your Listbox?
If there are string values in the listbox, your code is correct except for missing braces:
If the things in the listbox are some sort of object, you may need to override ToString() to get the desired result, or cast the thing you get out of the listbox to the desired type and then access an appropriate property.
Example: