Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Iterating through form's controls
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00407951
Message ID:
00407997
Views:
25
Roi,

Thanks a lot for your reply. I'll study this. In the meanwhile I decided to follow Larry's advice to add SetDefaultState method to Container class. In this method I'll put the code, as Cindy suggested:
for each loControl in this.Controls
      if left(lower(loControl.class),2)='bt' && BtCrit classes 
            loControl.SetDefaultState()
      endif
next

I don't have to go deep in hierarchy here.

Again, thank for your help.

>Hi Nadya,
>
>1) For examples of iterating through a forms controls see John K.'s Evil Bag-o-tricks, he does it in there. For another good example do a search for a message from Erik Moore with the word "runall" from about a year ago. Both use recursion AFAIK to do it.
>
>2) Recursion is going to be slow. You iterate each control and see if can contain controls, if so, go to a contained control and repeat. That happens for every button, textbox, label, pageframe, etc... on a form.
>
>I would think calling just the methods on the just the controls that need it would be faster. Also look at the SetAll method of the container, that might help as well.
>
>>Hi everyone,
>>
>>I have one very complicated form with pageframe with 8 pages. 6 first pages have Container1 on it. In each Page.Container1 I have bunch of different controls (criteria). I'd like to write a Form method SetDefaultState with would set each control (criterion) to its default state. Now my question is: what would be better from optimization point of view: use this construction:
>>
>>with this.PageFrame.Page1.Container1
>>    .control1.SetDefaultState()
>>    .control2.SetDefaultState()
>>    etc.
>>endwith
>>
>>with this.PageFrame.Page2.Container1
>>    .control1.SetDefaultState()
>>    .control2.SetDefaultState()
>>    etc.
>>endwith
>>  etc.
>>
>>
>>Or iterate through form's collection (not sure, how to do it)?
>>
>>Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform