Passing Custom Controls

DaveP

Member
Joined
Jan 24, 2008
Messages
12
Programming Experience
1-3
I have a custom control called NumberBox containing a label, a textbox and a combobox. It works fine, I have added it to my toolbox and used it on multiple forms.

Now I want to use a subroutine in a module to validate some of the instances of the custom control, but I find that when I use

Dim cntrl1 as Numberbox I get an error that Numberbox is not defined. In fact I get the same result in the code section of the form on which it occurs.

What should I have done to expose the control, its methods and properties.
 
part answered

Well, I've sort of answered my own question in that I find I can

Dim cntrl1 as ClassLibrary1.numberbox

but I would like to know why my Numberbox has to refer to the Root namespace, when my reference to the Numberbox.dll doesn't
 
when my reference to the Numberbox.dll doesn't
A library reference has nothing to do with that, it just loads the assembly into current AppDomain.
To use a type it must be in current namespace, or you must qualify (as you did), or import the namespace either locally or globally. Importing a namespace locally is done with Imports statement, globally in references tab in project property pages.

By the way, you can drag a library to Toolbox to add its controls there, or use the 'choose toolbox items' dialog. When you later drag a control to a form the reference is added automatically.
 
Back
Top