0

I am using Windows Forms, language - C#. I have a Project Calculator. I added a UserControl to that project ButtonC. I dragged that Control to my Form, and when running it, I am getting an error that ButtonC in does not exist.

Control Not Recognized Can't understand what is the problem. But When I manage that line like this

this.ButtonC = new ButtonC();

That does not give any error, but every time, before running I have to change that, and I don't think that it is the right solution. Thanks for Help.

1 Answer 1

2

I think the problem is that your ButtonC and your Calculator is in different namespace. Change them to the same namespace may solve the problem.

Edit:

I think I understand the problem. This should be a "bug" of auto-generated designer code. They simply put your namespace before your control, in your case it's "Calculator". But within the code, your namespace and your class are the same, thus the compiler interprets wrongly: it thinks Calculator.ButtonC is a subclass within Class Calculator.

If I'm not wrong, simply make your Namespace and your Class Name different may do the job.

Sign up to request clarification or add additional context in comments.

7 Comments

actually the Namespace is the same - Calculator
It seems that your designer treats the control as a Class within Calculator.Calculator, but actually it's within Calculator. Just remove the preceded Calculator, like what you mentioned in your post may do the job.
Yes, it works that way, but every time before after runing one time I have to remove that Calculator again and again :/
I think I understand the problem. This should be a "bug" of auto-generated designer code. They simply put your namespace before your control, in your case it's "Calculator". But within the code, your namespace and your class are the same, thus the compiler interprets wrongly: it thinks Calculator.ButtonC is a subclass within Class Calculator.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.