Vb net form activate deactivate




















The Activate event can occur only when an object is visible. A UserForm loaded with Load isn't visible unless you use the Show method. The Activate and Deactivate events occur only when you move the focus within an application. Moving the focus to or from an object in another application doesn't trigger either event. Copy these procedures into the UserForm1 module, and then add UserForm2. UserForm1's caption is created in its Activate event procedure.

When the user clicks the client area of UserForm1, UserForm2 is loaded and shown triggering UserForm1's Deactivate event, changing their captions. Have questions or feedback about Office VBA or this documentation? Microsoft makes no warranties, express or implied, with respect to the information provided here. The following example demonstrates the use of this member.

In the example, an event handler reports on the occurrence of the Deactivate event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing MessageBox. Show with Console. WriteLine or appending the message to a multiline TextBox. To run the example code, paste it into a project that contains an instance of type Form named Form1. The Resize event is fired continuously while the form is being resized.

The Scroll event is fired by forms that have their AutoScroll property set to True when the user scrolls the form. The second argument of the Scroll event handler exposes the OldValue and NewValue properties, which are the displacements of the form before and after the scroll operation.

The AutoScroll property is handy for large forms, but it has a serious drawback: It scrolls the entire form. In most cases, we want to keep certain controls in view at all times. This event takes place every time the form must be refreshed, and we use its handler to execute code for any custom drawing on the form.

When you switch to another form that partially or totally overlaps the current one and then switch back to the first form, the Paint event will be fired to notify your application that it must redraw the form. Skip to main content Skip to primary sidebar Skip to secondary sidebar. Handles Me. Cancel Then e. Resize Me.



0コメント

  • 1000 / 1000