How to make custom controls in VB Express

Hi all,

I have actually had some success at this but it works sometimes and sometimes it doesn't. I hope someone here can enlighten me so that I can achieve a consistent result.

the problem
I wish to create custom controls for use in other application I may make.

my current solution
Currently I follow the steps outlined below:
  1. open VB Express 2005
  2. select the Class Library template
  3. add a reference to System.Windows.Forms
  4. add a reference to System.Drawing
  5. add the line "inherits UserControl" to my class
  6. add the line "imports System.Windows.Forms"
  7. add the line "imports System.Drawing"
  8. add the line "imports System.ComponentModel"
  9. customize the user control through both the design and code views
  10. save and build the project
After I have created the custom control I do the following:
  1. open a new project
  2. select the Windows Application template
  3. add a reference to the .dll file created in the above procedures
At first this was working fine, and the custom control would show up in my tool box in the windows application that referenced the dll. However...

My new problems
I had gotten about halfway through a long process (making a custom control, making another that used the first, making another that used the second), when one time after some code changes and a re-build of some dlls, I got an error saying access to the xml of the very first control was denied. Whatever this means, ultimately it ends up that none of my other components can work because the bottom rung of the ladder is broken. I figured a file got corrupted somewhere along the way...and started re-doing the project all over from scratch.

But now...no components I make this way will show up in the toolbox when their dll is referenced in a new project.

It is most frustrating.

As I write, I am now wondering if I should try a repair-install of VBExpress2005

Thanks all,
--William


Answer this question

How to make custom controls in VB Express

  • kicke_

    The answer appears to be that now I must manually add the custom controls to the toolbox by right-clicking on the toolbox and selecting "Choose Items" (First I will add a tab, though)

    Why it once automatically added the controls I do not know, but it did, and it did so always in a new toolbox tab that carried the name of my custom control.

    At least it works, though.

    --William

  • krwoolf

    The best way to create a UserControl in VB2005 Express is this:

    1. Open VB Express 2005
    2. Select the Class Library template
    3. Select Project-Add New Item-Add User Control
    4. Delete the Class you created in step 2
    5. Add your code to the user control
    6. compile, debug, test
    7. When the user control is working proceed
    8. add new window project
    9. your user control will show in the Toolbox.

    I hope that helped...



  • How to make custom controls in VB Express