Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
HELP - need a control array in a class
Message
 
 
To
05/11/1998 23:50:08
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00155120
Message ID:
00155284
Views:
21
Robert,

Forget the control array in VFP if you are used to it in VB. VFP has a Controls[] collection which gives you access to all of the controls once they've been added to form.

Here's a code fragment that will get you started:
for i = 1 to 2
   for j = 1 to 35
      lcName = "Checkbox" + padl( i, 2, '0' ) + padl( j, 2, '0' )
      thisform.AddObject( lcName, "Checkbox" )
      loCheckbox = eval( "thisform." + lcName )
      with loCheckbox
         .Top = ( j - 1 ) * .Height + 4
         .Left = ( i - 1 ) * .Width + 20
         .Visible = .t.
      endwith
   endfor
endfor
>I've spent today with VFP 5.0 trying to end up with a two dimensional array of checkboxes. I've tried everything. Can someone please explain how? Quickly, I tried a control array, but I can't get the checkboxes to appear on a form if I dim an array and use createobject for each array element. Then I thought it'd be nice to create a container, (I prefer 2 dimensions ie 2,4 not just [8]), but couldn't get that to work. So I tried to code a descendant class of a container. Using a code snip from the book on line, it created a container with three command buttons as part of an array. Put in a prg, ran, created an instant in the command window. OK, then tried to
>"savetoclass". Everytime it would say "one of the members of this class is basedon a nonvisual class. Cannot write .vcx file". So I tried this method to simply save a form, and got the same error! Yet you can do it with the visual method, but can't create a control array that way.
>
>Simply, how can I create a control array of about 70 checkboxes that appear on a form? Can I create a class (although not necessary if there is an easier way). I would like it to be two dimensional. (rows and columns). Thanks in advance for any help.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform