Create an Object That Can Appear in the Component Tray

Problem

You want to create a class that has basic design-time support and can be added to a form’s component at design-time.

Solution

Derive your class from System.ComponentModel.Component.

Discussion

The .NET class library includes many classes that can be added to a form, Web page, or another type of component at design time. For example, as shown in Figure 4-1, you can add the System.Windows.Forms.Timer object class directly to the component tray of a form, even though it has no visual representation. This allows the programmer to configure properties and connect event handlers at design time.

Figure 4-1. A component object in the component tray.

To create a class that supports design-time creation, ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.