Compartir a través de


SetAll Method

Assigns a property setting on all, or a certain class of, controls in a Container object.

Container.SetAll(cProperty, Value [, cClass])

Parameters

  • cProperty
    Specifies the property to be set.

  • Value
    Specifies the new setting for the property. The data type of Value depends on the property being set.

  • cClass
    Specifies the class name (the class on which the object is based, not the Visual FoxPro base class for the object).

Remarks

Applies To: Column | CommandGroup | Container Object | Form | FormSet | Grid | OptionGroup | Page | PageFrame | _SCREEN | ToolBar

Use the SetAll method to set a property for all, or a certain class of, controls in a Container. For example, to set the BackColor property on all the Column objects in a Grid control to red, issue the following:

Form1.Grid1.SetAll("BackColor", RGB(255, 0, 0), "Column")

You can also set the properties for objects that are contained by other objects within the container. To set the ForeColor property of the Headers that are contained by each Column object contained in a Grid control to green, issue the following:

Form1.Grid1.SetAll("ForeColor", RGB(0, 255, 0), "Header")

Example

The following example uses the SetAll method with the DynamicBackColor property to specify the background colors for the records in a Grid control. If the number of a record displayed in the Grid is even, the record's DynamicBackColor is white, otherwise its DynamicBackColor is green.

A Grid control is placed on a form, and the customer table is opened and its contents displayed in the grid. The Caption property is used to specify a different header caption (Customer ID) for the CUST_ID field. A command button is placed on the form to close the form.

CLOSE ALL  && Close tables and databases
OPEN DATABASE (HOME(2) + 'Data\testdata')

USE customer  IN 0  && Opens Customer table

frmMyForm = CREATEOBJECT('Form')  && Create a form
frmMyForm.Closable = .f.  && Disable the window pop-up menu

frmMyForm.AddObject('cmdCommand1','cmdMyCmdBtn')  && Add Command button
frmMyForm.AddObject('grdGrid1','Grid')  && Add Grid control

frmMyForm.grdGrid1.Left = 25  && Adjust Grid position

frmMyForm.grdGrid1.SetAll("DynamicBackColor", "IIF(MOD(RECNO( ), 2)=0, RGB(255,255,255), RGB(0,255,0))", "Column")  && Alternate white and green records

frmMyForm.grdGrid1.Visible = .T.  && Grid control visible
frmMyForm.cmdCommand1.Visible =.T.  && "Quit" Command button visible
frmMyForm.grdGrid1.Column1.Header1.Caption = 'Customer ID'

frmMyForm.SHOW  && Display the form
READ EVENTS  && Start event processing

DEFINE CLASS cmdMyCmdBtn AS CommandButton  && Create Command button
   Caption = '\<Quit'  && Caption on the Command button
   Cancel = .T.  && Default Cancel Command button (Esc)
   Left = 125  && Command button column
   Top = 210  && Command button row
   Height = 25  && Command button height

   PROCEDURE Click
      CLEAR EVENTS  && Stop event processing, close form
      CLOSE ALL  && Close table and database
ENDDEFINE

See Also

Reference

SaveAs Method (Visual FoxPro)

SaveAsClass Method

Other Resources

Methods (Visual FoxPro)

Language Reference (Visual FoxPro)