O'Reilly logo

Microsoft® Visual Basic® .NET 2003 Kick Start by Joel Semeniuk, Erik Porter, Andy Baron, Duncan Mackenzie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extending Through Inheritance

Inheriting from an existing control provides a new control with all of the functionality (methods, properties, and events) of the existing class without writing a single line of code. The only code you have to write is for the functionality you are adding; the base class provides everything else for you.

Making a Simple Example

To create your own inherited control, start by adding a new class to an existing project, or by creating a “Class Library” project. Then, in the new class file, go through the following steps to build your very own custom text box that only allows numeric input.

First, you can save yourself a bunch of time by inheriting from System.Windows.Forms.Textbox. You do this by adding Inherits System.Windows.Forms.Textbox ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required