User Controls

Deriving from an existing control is one way to reuse it, but the most popular form of reuse for a control is simple containment, as you're accustomed to doing when building custom forms using existing controls. A user control is a way to contain a set of other controls for reuse as a set, producing a kind of “subform.” For example, imagine that we wanted a control that composed our FileTextBox control with a “…” button for browsing. In use, it would look like the one shown in Figure 8.21.

Figure 8.21. A Sample User Control in Action

It's hard to tell from the picture, but as far as the form in Figure 8.21 is concerned, it's containing ...

Get Windows Forms Programming in C# 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.