Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Listbox and Array Property and where to do what
Message
De
16/05/2001 03:38:53
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
15/05/2001 16:20:29
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00507493
Message ID:
00507704
Vues:
10
>I have a listbox using a form array property. I create and dimension the array property in the form's Init method and then populate it in a command button on the form. This works fine. The problem is that I want the listbox to populate when the form is called; I used the command button just to see if it would work as I was frustrated on trying to figure it out. No matter where I put the code that fills the array, other than in code that I will manually trigger, it always says that the array doesn't exist or it does exist, but no values appear. I think the difficulty lies in my lack of understanding regarding when things get called and the order of events firing. I know there's this "inside-out" logic to object and their parents, but I was pretty sure that by putting the code in the listbox Init I wouldn't have any problem. Why does the code in the command button work and not anywhere else? Anyone have insight to both the specific problem and/or the big picture? Thanks!
>
>Regards, Renoir

Renoir,
Probably array you use is not a form property and not declared as public. IOW sounds a scope problem. ie:
* Listbox init - would work
With thisform
  Dimension .myArray[10,2]
  For ix=1 to alen(.myArray,1)
    .myArray[ix,1] = 'ID'+padl(ix,5,'0')
    .myArray[ix,2] = 'P'+padl(ix,5,'0')
  Endfor
Endwith
With this
  .ColumnCount =ALEN(thisform.myArray,2)
  .Columnwidths = '100,100'
  .NumberOfElements=ALEN(thisform.myArray)
  .RowSourceType=5
  .RowSource='thisform.myArray'
Endwith

* Listbox.init - would work too
public array aArray[10,2]
for ix=1 to alen(aArray,1)
	aArray[ix,1] = 'ID'+padl(ix,5,'0')
	aArray[ix,2] = 'P'+padl(ix,5,'0')
endfor
With this
  .ColumnCount =ALEN(aArray,2)
  .Columnwidths = '100,100'
  .NumberOfElements=ALEN(aArray)
  .RowSourceType=5
  .RowSource='aArray'
Endwith

* Above would work from a command button even if array was local
* It's in scope there during population
* It wouldn't work from listbox.init if array is local
If you want to make it from listbox init with local array then use AddListItem() instead.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform