| Initialize · The Initialize event occurs when an application creates an instance of a Form, MDIForm, or class. · The Initialize event is typically used to prepare an application for use. Examples of such are assigning initial values to variables, to move controls and/or to resize controls to accommodate initialization data. · The Initialize event will fire only once during the life of the application. To fire the Initialize event again, you must exit and restart the application. So a form that's unloaded, and then redisplayed will not trigger the Initialize event a second time, or at all. Load · The Load Event is used to perform actions that need to occur prior to the form being displayed. It is also used to assign default values to the form and its controls. · Remember that the Load event is fired after the Initialize event, and a form loaded using the Load statement isn't visible unless you use the Show method, or set the form's Visible property to True. · A forms Load event can fire multiple times during an application's life. This happens when a form start as the result of the Load statement, Show statement, or when a reverence is made to an unloaded form's properties, methods, or controls. Activate · The Activate event fires when the form receives focus from another form within the same project and this event fires only when the form is visible. · Remember also that the GotFocus event fires after the Activate event. · The Activate event fires only when focus is changing within the same application, not if you set the focus to a different application and then return to Visual Basic program. Deactivate · The Deactivate event fires when the form loses focus to another form. · This event then fires after the LostFocus event. · The Deactivate event fires only when changing within the same application, not if you set the focus to a different application. QueryUnload · The QueryUnload event is very useful when you need to know how the user is closing the form. · The UnloadMode argument of the QueryUnload event informs you how the form was closed and allows the cancellation of the event. · Some actions may cause the QueryUnload event to fire. Actions like the user chooses the Close command from the Control menu, invoke the Unload statement from code, current Microsoft Windows operating environment session is ending, Microsoft Windows Task Manager is closing the application or an MDI child form is closing because the MDI form is closing. · To stop a form from unloading, set the Cancel argument of the QueryUnload event to True. Unload · The Unload event occurs before the Terminate event. · Use the Unload event procedure to verify that the form should be unloaded or to specify actions that take place when unloading the form. · An example of such an action will be to include form-level validation code needed to close the form or to save data to a file. · All forms will be unloaded from the application if the End statement is added to this event. · Important, setting Cancel to any nonzero value prevents the form from being removed, but doesn't stop other events, such as exiting from Microsoft Windows operating environment. Alternatively use the QueryUnload event to stop Windows from shutting down. Terminate · The Terminate event occurs when all references to an instance of a Form, MDIForm, or class are removed from memory. · If a Class is remove because the application terminated abnormally the Terminate event will not fire. · For Classes the Terminate event will occur before the Unload event. |
Form Events |
Express News India | Freelance ecommerce web development India