Board index » cppbuilder » How to set the TListBox->selected[i]?

How to set the TListBox->selected[i]?

I have some code that attempts to set an item in a list box as selected by
myListBox->Selected[i] = true;  But this always throws an error "List index
out of bounds".  How can I do this?  BTW, my number IS in bounds.

Keith

 

Re:How to set the TListBox->selected[i]?


The problem might lie in the setting of the property multiselect.  Try
changing the value of that property and then running the application.

You may need to look at using the WinAPI for what you want to do.

HTH,

Brent

Re:How to set the TListBox->selected[i]?


Hi, Keith

you may start your loop with 0, e. g,

   for (int i = 0; i < myListBox->Items->Count; i++) {
      myListBox->Selected[i] = true;
   }

Hope this can help you.

Roman

Other Threads