Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can you select items in a listbox by value?
Message
From
14/12/2000 14:46:15
 
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00453572
Message ID:
00453578
Views:
19
>Is it possible to programmatically select item(s) in a listbox by the value(s) instead of using the Index or ItemID?
>
>Thanks,
>- 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
Insanity: Doing the same thing over and over and expecting different results.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform