Share via


Visual Basic Concepts

Events Your Control Should Raise

Recommended events include Click, DblClick, KeyDown, KeyPress, KeyUp, MouseDown, MouseMove, and MouseUp. It's also a good idea to implement events commonly found on controls that provide functionality similar to yours.

In addition, you may wish to selectively implement events of the constituent controls on your UserControl object, or of the UserControl object itself.

It's important to use the same arguments, with the same data types, as these standard events, as discussed in "Exposing Events of Constituent Controls." Data types are discussed in "Using Standard Control Property Types."

Using the ActiveX Control Interface Wizard

The ActiveX Control Interface Wizard can assist you in determining what events to provide, and in forwarding the appropriate constituent control events.

After you have placed all the constituent controls you're going to use on your UserControl, start the wizard and select your control. The wizard will examine your constituent controls, and produce a list of all the properties, methods, and events that appear in all their interfaces, plus those in the UserControl object's interface, and the standard events listed above. You can select from this list those properties, methods, and events you want in your control's interface.

The wizard will produce default mappings of your control's events to events of the UserControl object or of constituent controls. In subsequent steps, you can modify these mappings.

When you have finished determining your control's interface, the wizard will generate code to raise the events you've selected, using the correct arguments and data types for standard events, and including event forwarding code for all your event mappings. This enormously reduces the amount of work required to generate a full-featured control.