Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Array of controls, buttons, checkboxes????
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00281367
Message ID:
00281833
Vues:
13
>>Is there a way to create a double dimensioned array of items such as checkboxes. I am attempting to make a calendar control and it would be alot easier to set my "grid" of 6 rows by 7 columns properties accordingly using an array instead of physically coding ... "thisform.box1.caption="1", thisform.box2.caption="2",... and using something line "thisform.box(r,c).caption=counter". Any suggestions?
>>
>>Thanks
>
>Yes you can. Add a property to the form with the name Box(1). Place all of your checkboxes in a container. In the container's Init do this;
>
>
>WITH Thisform
>   DIMENSION Box(6,7)
>   .Box(1,1) = This.chkBox1
>   .Box(1,2) = This.chkBox2
>   .Box(1,3) = This.chkBox3
>   .Box(1,4) = This.chkBox4
>   .Box(1,5) = This.chkBox5
>
>   ...
>
>ENDWITH
>
>
>Now you can iterate through the checkboxes with;
>
>
>WITH Thisform
>   FOR x = 1 TO 6
>      FOR y = 1 TO 7
>         .Box(x,y).Value = Whatever
>      ENDFOR
>   ENDFOR
>ENDWITH
>
And since all arrays are really one dimensional, the second dimension being a logical concept, you could use AELEMENT in the initial assignment of checkboxes to Box(x,y) and do it all in your nested FOR loop.

WITH Thisform
DIMENSION Box(6,7)
FOR x = 1 TO 6
FOR y = 1 TO 7
whichbox = 'This.chkBox' + padl(AELEMENT(.Box,x,y),2,'0') && same as ((x-1) * 7) + y
.Box(x,y) = &whichbox
.Box(x,y).Value = Whatever
ENDFOR
ENDFOR
ENDWITH
** assuming the checkboxes are named chkBox01 through chkBox42
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform