Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using ListBoxes with arrays.
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Using ListBoxes with arrays.
Divers
Thread ID:
00007084
Message ID:
00007084
Vues:
82
I thought I would share my experience regarding this topic:

If anybody needs very fast pick lists in an application (because for example, the end user will be making several sequential choices from a series of "rapid fire" pick lists), then you might consider using ListBoxes to instantiate your pick lists and populate them using arrays. Here is my situation:
-- I know that the number of items in any given pick list will be relatively small (less than 30).
-- I am using a relatively sophisticated but small lookup table (a few hundred small records), which is indexed, to populate the pick lists. By sophisticated, I mean that a choice made in one picklist determines which pick lists will be subsequently displayed, and this algorithmic branching is all controlled by the lookup table. My code is basically a data-entry framework that does what the lookup table tells it to do.
-- I have found that a SEEK followed by a COPY TO ARRAY on the indexed lookup table is very fast, much faster than SELECT/SQL into an array.
- As is almost always the case when using a lookup table, I need to retrieve at least two columns: one for display, the other holding a unique key for each displayed item.

What was causing me so much confusion was how to use a multidimensional array (RowSourceType=5) with a ListBox. Unusual things happen when you change ColumnCount to any value other than zero. When you do, the NumberOfElements property simply does not control the contents of the ListBox the way it should. The only workaround is to continually redimension the array to exactly the number of rows retrieved from the lookup table. Sloppy and slower but it works.

On the other hand, if you leave ColumnCount set to zero, then setting NumberOfElements will determine the number of items displayed in the ListBox (apparently synonymous with ListCount). You will always get a single column displayed in the ListBox. If you want the listbox to display the first column of the array, set FirstElement to 1. To display the 2nd column within the Listbox, set FirstElement to 2, and so on. To retrieve a value from a different column when the user chooses an item from the LisBox, just use the value of the ListIndex property to access the correct row in the array.

I have still not figured out how to do something like this: With an Nx3 array, display the second and third column but not the first. Or with any NxM array using ColumnCount greater than zero, exercise control over how many rows of the array are actually included in the display.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform