Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Listbox problem about storing data from array
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00671233
Message ID:
00671257
Vues:
16
Yeung,

The problem is that the array only exists while the Init() method is executing. When the Init() finishes the array disappears and takes away the data for the listbox to display.

There are 3 easy solutions to this

1) use a form level array, that will maintain scope throughout the lifetime of the listbox:
DIMENSION thisform.adata(3)
with thisform
   .adata[1]="a"
   .adata[2]="b"
   .adata[3]="c"
endwith

this.Requery()
You can assign all of these properties on the Property Sheet at design time:

this.rowsourcetype = 5
this.rowsource = "thisform.adata"
this.firstelement = 1

2) Encapsulate the array right into a subclass of the Listbox. This requires a little more front end work, but in the long run is better than option #1 because it's better OO.

3) Use the AddItem() and AddListItem() methods to populate the control, this can be a hassle when you are using more than 1 column.

>I am trying to input an array into a listbox, but I am failed. The data never be shown inside the listbox.
>
>Even I tried these codes in the listbox init event.
>DIMENSION adata(3)
>adata[1]="a"
>adata[2]="b"
>adata[3]="c"
>this.rowsourcetype = 5
>this.rowsource = "adata"
>this.firstelement = 1
>
>What's wrong on my code?
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform