Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Controls collection at design time
Message
 
 
To
21/01/2004 17:29:25
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00869260
Message ID:
00869275
Views:
15
Works for me, but you need to change OF to IN in the FOR EACH line. What I would do is create an array in the FOR EACH and store an object reference to each form object. Then loop through the array to change out your form objects. In VFP8 you could use Collection object.

>I'm writing a builder which replaces controls. It finds objects of certain class, adds a different object of the new class, copies properties from the old one, RemoveObject()s the old one.
>The trouble is how to do this in a loop. If I try going for i=1 to oParent.ControlCount, as soon as I remove the old one, the whole collection is reshuffled. I'll probably fix it by doing for i=oParent.controlcount to 1 step -1, so those I replaced will be removed from the current position and new ones added in the end, which would be just OK (except the instantiation order would now be reverse - but this should not be important, or there's something wrong with the design).
>
>The trouble I have is when I attempt to do For Each oMember of loObj.Controls - it gives me syntax error for a form with just two objects (a pageframe and a custom). The collection is visible in debugger while the builder runs, and also in the command window - any member of the collection can be accessed by number. It's just that For Each it gives a syntax error.
>
>VFP7 SP1. Can anyone check whether this works in VFP8?
>
>
* have a form with a few controls open for editing
>aselobj(oForms,1)
>oForm=oForms[1]
>for each oControl of oForm.controls
>   ? oControl.name
>endfor
>Save this in a prg and run it while editing a form, I need to know whether anything changed here in VFP8.
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform