Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can you select items in a listbox by value?
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00453572
Message ID:
00453592
Views:
30
Brian,

It was said here multiple times, that it's better not use ListBoxes (especially multiselect listboxes) for number of items greater than 100. If you'd use them for 5000 items, you definitely find bunch of problems. I already found this, so then I switched to multiselect Grid (available here in Files section - file by Cetin Basoz). I created quite complicated class based on Cetin's class and posted it also in Files section. You may want to take a look at both of them.

>Ok, thanks Trey,
>
>I wanted to try and avoid having to loop through all the values, expecially since the RowSource table could contain upwards of 5,000 records... but, oh well... I'll see how your suggestion works.
>
>- Brian
>
>>
>>Not directly
>>Depending on the RowSourceType, there a number of options - this ought to work for any RowSourceType
lcSearch = "findthis"
>>With thisform.list1
>>     For ji = 1 To .ListCount
>>          If .List(ji)=lcSearch
>>               .ListIndex = ji
>>               Exit
>>          EndIf
>>     EndFor
>>EndWith
If the RowSourceType is an array or a alias or fields, you can go directly to the RowSource and find the value which will reflect in the listbox. e.g., if RowSourceType is an array, e.g., thisform.aSource
With thisform
>>     .list1.ListIndex = Ceiling(AScan(.aSource, lcSearch)/ALen(.aSource,2))
>>EndWith
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform