Creating Custom UserControls

Essential to creating powerful user interfaces and cutting down on redundant work is creating custom controls. Whenever you contrive a partial solution that can be used more than one time, create a control.

The easiest way to create a control is to add a UserControl to your project. The UserControl acts as a drawing surface that you can paint a variety of controls onto and reuse that control. To create a user control and add it to the toolbox, follow these steps:

1.
Create a new Windows Control Library.
2.
From the Visual Studio .NET main menu, click Project, Add User Control.
3.
Add the controls, code, and events to describe the behavior supported by your user control.
4.
Compile the Class Library containing ...

Get Visual Basic® .NET Unleashed 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.