Condividi tramite


Init Event

Occurs when an object is created.

PROCEDURE Object.Init
[LPARAMETERS Param1, Param2,...]

Parameters

  • Param1, Param2...
    Parameters are optional, but if parameters are passed, you must include an LPARAMETERS or PARAMETERS statement that lists each parameter. Otherwise, Visual FoxPro generates an error.

Remarks

For form sets and other container objects, the Init events for all the contained objects are triggered before the container's Init event, so you can access the contained objects within the container's Init event. The Init event for each contained object occurs in the order it was added to the container object.

To prevent a control or an Active Document from being created, return false (.F.) from the Init event. The Destroy event will not be triggered. For example, the following code returns false (.F.) if the Invoice table is not available:

PROCEDURE INIT 
  IF NOT FILE("INVOICE.DBF") 
  ERROR 'Initialization Failed: File not found' 
  RETURN .F. 
  ELSE 
  USE INVOICE IN 0 AGAIN 
  THIS.WorkArea = SELECT() 
  ENDIF 
ENDPROC

See Also

AddObject Method | CREATEOBJECT( ) | Load Event

Applies To: ActiveDoc Object | CheckBox | ComboBox | CommandButton | CommandGroup | Container Object | Control Object | Cursor | Custom | DataEnvironment | EditBox | Form | FormSet | Grid | Image | Label | Line | ListBox | OLE Bound Control | OLE Container Control | OptionButton | OptionGroup | Page | PageFrame | ProjectHook Object | Relation | Session Object | Shape | Spinner | TextBox | Timer | ToolBar