How to Use Collection Array Property for Object Container

ID: Q130713

3.00 WINDOWS

The information in this article applies to:

  • Microsoft Visual FoxPro for Windows, version 3.0

SUMMARY

In Visual FoxPro, all the object containers in a form have a collection property associated with them. The collection property is an array that references each container object. You can reference properties and methods by using the collection array property rather than a specific object name.

For example, the collection array property for a CommandGroup button is buttons(). The following example changes the caption of the first command button in the CommandGroup named CommandGroupName:

    CommandGroupName.Buttons(1).Caption = "New"

MORE INFORMATION

The following table lists the object containers that create an array property when the object containers are created.

   Object Container       Collection Property
   ------------------------------------------
   Formsets               Forms
   Forms                  Controls
   PageFrame              Pages
   Page                   Controls
   CommandGroup           Buttons
   OptionGroup            Buttons
   Grid                   Controls
   Column                 Controls

For more information on the collection property, search the Help file for
'Collection Properties'.

Sample Code

The following example toggles the enabled property of all text boxes on a form to the inverse of the value of its current enabled property. In other words, if the text box enabled property is equal to true (.T.), the code set it to false (.F.):

   FOR icount = 1 TO Thisform.controlcount
      IF UPPER(Thisform.Controls(icount).Class) = "TEXTBOX"
         Thisform.Controls(icount).Enabled = ;
            !Thisform.Controls(icount).Enabled
      ENDIF
   ENDFOR

Additional reference words: 3.00 VFoxWin kbfest KBCategory: KBSubcategory: FxtoolFormdes
Keywords          : kbcode FxtoolFormdes 
Version           : 3.00
Platform          : WINDOWS


Last Reviewed: May 22, 1998
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.