I am using a checked list box but for some reason I can not ficure out how to retrieve the text from a specific index...
I tried this
clbModels.GetItemText(1)
but all I get is the index back... Any ideas?
Printable View
I am using a checked list box but for some reason I can not ficure out how to retrieve the text from a specific index...
I tried this
clbModels.GetItemText(1)
but all I get is the index back... Any ideas?
try
x being the indexCode:CheckedListBox1.Items(x).ToString()
Thanks.. That works beautifuly.. :DQuote:
Originally Posted by kleinma
So what exaclt is "GetItemText" for? According to the object browser it should do the same thing..
"Summary:
Returns the text representation of the specified item.
Parameters:
item: The object from which to get the contents to display. "
object browser = poo
msdn = yay
basically it does the same exact thing... BUT if you look at the help file on MSDN, the param you pass to the GetItemText method is not the index... its the object itself...
so it makes sense that you pass the object "1" to it, that it spits it right back at you, because its simply calling ToString on "1", which gives you.. well.. "1" :bigyello:Quote:
item
The object from which to get the contents to display.
so if you have the OBJECT in question (since listboxes can hold objects, not just text, but can only display the ToString of the objects they hold) using the method I gave is simply the easiest way to go about it
Sounds good to me.. :D
Thanks again,
Rudy