You will learn about the following in this chapter:
At the time of this writing, more than three dozen Windows Forms controls are being shipped with Visual Basic .NET. If you include other controls that are not used with Windows forms, such as Web controls, the count increases to more than 50 controls. Everything you need is there for you on the toolbar, right? Well, not quite. No matter how many controls are bundled with Visual Basic .NET, each programming task has little nuances of difference that make programmers wish for controls that do this or that. Alas, if the only tool you have is a hammer , pretty soon every problem starts to look like a nail.
You need a variety of tools to do a job right, and Visual Basic .NET gives you a pretty robust selection. If you really do have a problem that one of the Visual Basic .NET tools can't even come close to solving, however, you can check the Visual Basic .NET magazines or the Internet for an appropriate tool. Purchasing off-the-shelf controls is often a cost-effective and smart way to program a solution.
Still, there are a lot of situations in which the Visual Basic .NET tool set comes close to what you need, but it's not quite a perfect fit. The circumstance is not as bad as "round hole, square peg" situation; it's more like a "round hole, oval peg" problem. This chapter shows how to turn oval pegs into round ones; that is, it shows you how to craft your own custom controls.
You can approach the problem of crafting your own custom controls by using any one of three general methods:
This chapter shows how to combine the first two methods to build a new control. You'll learn how to build a custom control from three text box controls. Inheritance provides the lion's share of the new control's functionality. When you understand the basics of building a custom control, you will find it pretty straightforward to build new controls from scratch.