Reputation: 479
I've created my own custom control and added it to my toolbox. It works, I can drag it to the Form, access its properties though code ect... But I cannot create it dynamically? Like for instance a button would be:
Button btn = new Button();
But when I try my control:
CustomControl x = new CustomControl();
I get: "Type or namespace name 'CustomControl' could not be found"
I add the .dll to my references and I try the above code, to only get: "'CustomControl' is a 'namespace' but is used like a 'type'"
What am I missing here?
Thanks
Upvotes: 0
Views: 394
Reputation: 4657
I think you are using namespace
instead type
. namespace
is just a Case and you can not create a new one using the last namespace. try to find what class is in the namespace and construct a new one(using CustomControl.Cl c=new CustomControl.Cl();
but not try to use CustomControl x = new CustomControl();
I think the reason is that the namespace
does not have any constructor
ant it can't construct but class
have constructor
.
because the namespace's concept if for Classification your classes and another things and it doesn't exist int the general code.
Upvotes: 0
Reputation: 307
It sounds like maybe your CustomControl is in a namespace called CustomControl. If that's the case, then rename one of them.
Upvotes: 1