c# - How do you get the text from a listbox by index? -


i trying text entry in winforms listbox index, seem stumped. logical thing can think of is:

listbox.items[index].tostring 

but not return desired result.

does know how this?

what have in listbox?

if there string values in listbox, code correct except missing braces:

string value = listbox.items[index].tostring(); 

if things in listbox sort of object, may need override tostring() desired result, or cast thing out of listbox desired type , access appropriate property.

example:

myclass = (myclass)listbox.items[index]; string value = my.somepropertyofmyclass; 

Comments

Popular posts from this blog

JQuery Autocomplete without using label, value, id -

c++ - Accessing inactive union member and undefined behavior? -

JAVA - what is the difference between void and boolean methods? -