Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Creating a Custom Control

With Visual Basic .NET, you have the ability to create custom, managed controls. If you’ve ever built ActiveX controls in Visual Basic 6, you already know how to accomplish this. I’ll briefly touch on the highlights of control construction by illustrating how to build a simple control that raises an event in the host.

Changing the Background Color of a Text Box

As you know, a control cannot exist on its own but instead needs a host container such as a form to exist. In this example, we’ll create a control that contains a context menu and permits the user to change the control’s background color. The example is admittedly simple and contrived, but all of the main points are illustrated. A sample of our control is shown in Figure 14-7.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial