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
Applies To: CheckBox | Collection Class | Column | ComboBox | CommandButton | CommandGroup | Container Object | Control Object | Cursor | CursorAdapter Class | Custom | DataEnvironment | EditBox | Exception Class | Form | FormSet | Grid | Header | Image | Label | Line | ListBox | OLE Bound Control | OLE Container Control | OptionButton | OptionGroup | Page | PageFrame | ProjectHook Object | Relation | ReportListener Object | Session Object | Shape | Spinner | TextBox | Timer | ToolBar
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 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