1. Computing

User Control Components in VB.NET

CalcPad in VB.NET 1.X

By

You will have a small problem if you have the VB.NET 1.X Standard Edition. User controls have to be created as DLL's to be used in other projects and this version won't create DLL libraries "out of the box". It's a lot more trouble, but you can use techniques described in this article to learn how to get around this problem.

With the more advanced versions:

  • Create a new Windows Control Library. The illustration below shows the VB.NET 1.X dialog.

--------
Click Here to display the illustration
Click the Back button on your browser to return
--------

  • From the VB main menu, click Project, then Add User Control. This gives you a form design environment almost identical to the one you use for building standard Windows applications.

--------
Click Here to display the illustration
Click the Back button on your browser to return
--------

  • Add the components and code for your control and customize the properties you need. You can copy and paste from your debugged standard Windows app. In fact, the code for the CalcPad control (more on this in a few pages) was copied with no changes.
  • Build your solution to get the DLL file for your control. Remember to change the Configuration to Release before the Build for production use.
  • To move the control to the Toolbox, right-click on the Toolbox and select Add/Remove Items ...
  • Using the .NET Framework Components tab, Browse to the DLL for your component (probably in the bin folder of the Windows Control Library solution). Click Open when the DLL file is selected to move the control to the Toolbox, then click OK. The illustration below shows CalcPad in the VB.NET 1.1 Toolbox.

--------
Click Here to display the illustration
Click the Back button on your browser to return
--------

To check out your work, you can close the Windows Control Library solution and open a standard Windows Application solution. Drag and Drop your new CalcPad control and Run the project. The illustration shows that it behaves just like the Windows calculator, but it's a control in your project.

--------
Click Here to display the illustration
Click the Back button on your browser to return
--------

This isn't everything you need to do to move the control into production for other people, but that's another subject! The 1.1 version of CalcPad (and the other versions too) can be downloaded at the end of the article.

  1. About.com
  2. Computing
  3. Visual Basic
  4. Using VB.NET
  5. User Control Components in VB.NET

©2014 About.com. All rights reserved.