Hi, I'm just starting to learn how to create custom controls in C# but I'm having a problem with the toolbox here.
After creating and compiling the custom control in the Library project, i add new project to the solution to test my new control, so i add reference like every tutorial instructs. However, i got stuck because of the toolbox, it does not display my control, can anybody help telling me what the problem is?
Do your controls inherit from UserControl or Control? if they don't inherit from one of those they can't be added.
Furthermore, Its likely that you custom control doesn't have a public constructor. and there should be a constructor that takes 0 args, even if your control needs to take some args, in order for the toolbox to work right there needs to be one with 0 args.
hope this helps. Its hard to help without seeing the code.
try this, create a new project, add a new class call it mybutton, then change it to inherit from System.Windows.Forms.Button save it and compile. then close the empty for that appears, and look in the tool box, at the very top there should be a gear icon with "mybutton" next to it. It should be that simple.
I tried your instructions but got stuck because it requires overiding some methods.
If you can then have a look at my code, it's just a simple one, and may i ask one more thing, i tried to add my control to the test form using codes, but when i use it, the event onClick is never performed, did i do something wrong in the code? Thanks very much for your concern.
I'm not sure what you mean about it requiring that you override some methods. But that's not your problem. You added a reference to the debug dll of the class library, when your class library is in the same project you add a reference using the "project" tab of the add reference dialog. I made this switch and now everything works as it should and the logincontrol appears in the toolbox at the top.