Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing Form Controls as a Collection
Message
From
03/04/2006 16:32:25
 
 
To
03/04/2006 15:33:00
Joel Whitehead
Ccs Central Computer Services Inc.
Thunder Bay, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01110059
Message ID:
01110076
Views:
14
For example, cycle through all the controls on a page, and for any text boxes, set the font to bold, or some such thing. I told him that we would normally create a text box class and have all the text boxes inherit from that. However, it did make me wonder if there is a way to accomplish this similar to how he has described to me.

Add a method to your form called DrillDown and when you call it the first time, pass Thisform to the method. This code in DrillDown() method:
LPARAMETERS toControl
LOCAL loPage, loControl, loColumn
DO CASE
  CASE UPPER( toControl.BaseClass ) = 'PAGEFRAME'
    FOR EACH loPage IN toControl.Pages
      Thisform.DrillDown( loPage )
    ENDFOR

  CASE INLIST( UPPER( toControl.BaseClass ), 'PAGE', 'CONTAINER' )
    FOR EACH loControl IN toControl.Controls
      Thisform.DrillDown( loControl )
    ENDFOR

  CASE UPPER( toControl.BaseClass ) = 'GRID'
    WITH toControl
      FOR EACH loColumn IN .Columns
        FOR EACH loControl IN loColumn.Controls
          *** Do something to the contained controls
        ENDFOR
      ENDFOR
    ENDWITH
  
  CASE INLIST( UPPER( ALLTRIM( toControl.BaseClass ) ), 'COMMANDGROUP', 'OPTIONGROUP' )
    FOR lnButton = 1 TO toControl.ButtonCount
      ThisForm.DrillDown( toControl.Buttons[lnButton] )
    ENDFOR
		
  OTHERWISE
    *** Do what needs doing here
ENDCASE			
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform