User defined Control Problem

bghanim

Active member
Joined
Dec 5, 2006
Messages
40
Location
Abu Dhabi - UAE
Programming Experience
1-3
Hello All,
I've created a control that inherits TextBox, and it's working correctly i.e. I can put an instance of it on the form design, and every thing is working as I need at run time.

But there's a problem with it, that I can't declare an instance of it through the code (to create a control dynamically).

dim txt as new numaricTextBox

The error is "Type Expected" and a blue line is displayed under umaricTextBox


Any help will be appreciated.

Regards,
Baha
 
Is "numaricTextBox" really the name of your inherited class? Look in the controls code, does it say "Public Class numaricTextBox"?

Another issue could be if your control belongs in a class library, then it could be inside this namespace, for example "ClassLibrary1.numaricTextBox".
 
it's a DLL file i.e. after I create my own control that inherits textBox (Windows Control Library Project), I compiled the project. Then in my application I referenced that DLL file through Project menue --> Add reference

After that I dded this control to the ToolBox.
in the form design, I can put many instances of it, but by code I can't declare any instance of it.


Regards,
Baha
 
I've solced the problem, it seems that I should include the project name before calling the instance i.e.
dim txtBox as numaricTextBox.numaricTextBox


but why it should be declared as thateven I have my own DLL file
 
If not adding it by toolbox you have to manually Add Reference to that dll file. Also look in it's project properties and read out the Root Namespace. After this you have the reference and may create the instance "dim x as new rootnamespace.classname"
 
Back
Top