| You are here: | About>Computing & Technology>Visual Basic> Using VB.NET> Inheriting Controls in VB.NET |
![]() | Visual Basic |
Inheriting Controls in VB.NETNov 13 2006 Improving the code from Microsoft (or a third party control supplier)One big improvement in Visual Basic .NET is the great new controls in the Toolbox. Controls like WebBrowser (new in VB 2005!) make your programming life easier and more automatic. Even standard forms like Button and TextBox are vastly improved from their VB 6 versions. But what if a control just isn't quite right? What if you would like a reusable control that has just a few differences? This article explains how to make that happen for you. (And describes how to get around what seems to be a serious bug in Microsoft's Visual Studio .NET 2005. More on this later.) The techniques described in this article are not possible with VB Express, unfortunately, because Microsoft doesn't provide a template for Windows Control Libraries in VBE. First, credit where credit is due. In writing this article, I used Mastering Microsoft Visual Basic 2005 (ISBN: 0782143490) by Evangelos Petroutsos extensively. I consulted two other "thick" VB 2005 books for the same information and only this one delivered the goods. Why would you want to create your own control? There are probably more reasons than there are programmers. But let's look at some typical examples.
There are three basic ways that you can create a custom Windows Forms control in VB.NET.
This article explores the first method. (The CalcPad control, explained in the article User Control Components in VB.NET explains the second method.) Let's create a very basic control by inheriting what might be the most common control, Button, to get the technique down first and also, to see what to do about a problem I ran into. The rapid fire description of the technique goes like this:
Your control is ready to use! |
Las Vegas on a BudgetFind a BargainHotel DealsCheap EatsFree AttractionsEntertainment for Less |
All Topics | Email Article | | | ![]() |
| Advertising Info | News & Events | Work at About | SiteMap | Reprints | Help | Our Story | Be a Guide |
| User Agreement | Ethics Policy | Patent Info. | Privacy Policy | ©2008 About, Inc., A part of The New York Times Company. All rights reserved. |


