Visual Basic Concepts

Allowing Developers to Edit Your Control at Design Time

Some controls, like the OLE control supplied with Visual Basic, allow you to edit the control's contents at design time. You can enable this behavior for your control by setting the EditAtDesignTime property of your UserControl object to True.

If a container supports this feature, it will add an Edit menu item to the context menu that appears when a developer right-clicks on an instance of your control at design-time.

The developer using the control can activate a control instance by right-clicking the control to get the Context menu, then clicking Edit. The control will be activated, and will behave as it does at run time.

This allows you to author controls with visual design features, such as letting the user size rows and columns, or set property values by typing directly into constituent controls. You can detect whether your control is running at design time by testing the UserMode property of the AmbientProperties object. This property is False at design time.

The control only remains active while it is selected. When the developer clicks on another control, the control will deactivate. To reactivate the control, the developer must select Edit from the context menu.

Note   When your control is activated in this fashion, the events of the UserControl object will occur, so that your control can operate normally, but your control will be unable to raise any events. The RaiseEvent method will simply be ignored; it will not cause an error.