Hi guys, here is a question about a custom control.
When I wanted to create a custrom control from scratch, I followed the
steps as bellow,
1. Create a new contorl liabrary project.
- but why does VS2005 create a UserControl derived class at first?
2. Add a newItem (custom control) to the proj.
- ok, a custom control derived from Control is created, as
expected.
Then, I built a dll, and added it to another app proj, as well as the
toolbox.
But I found two control listed in the toolbox - a custom contorl and a
user control.
I am wondering why a user control was created automatically.
Is it a must?
Can someone explain it to me?
Thx in advance.
Tim Wilson - 26 Feb 2006 14:29 GMT
The "Windows Control Library" template sets up a UserControl. You can clean
up this after the fact and change to inherit from Control, and any other
clean up that must be done, or you can just create a "Class Library" project
and then add a reference to the "System.Windows.Forms" assembly and inherit
the generated class from Control. My guess is that when you added the new
class you forgot to remove the auto-generated class that represents the
UserControl. Try looking at the class files through Solution Explorer and
seeing if a class that represents the UserControl is present.

Signature
Tim Wilson
.NET Compact Framework MVP
> Hi guys, here is a question about a custom control.
> When I wanted to create a custrom control from scratch, I followed the
[quoted text clipped - 16 lines]
> Can someone explain it to me?
> Thx in advance.
Buddhist.CHinA@gmail.com - 27 Feb 2006 02:38 GMT
Thx Tim.
Yes, I haven't removed the auto-generated user control class, since I
thought it was a must.
Your second approach is very convenient to create a custom control.
Thx.
Tim Wilson - 27 Feb 2006 02:54 GMT
> Yes, I haven't removed the auto-generated user control class,
> since I thought it was a must.
The templates are just a starting point. Once you've created a project from
a template, you can add or remove items as you see fit.

Signature
Tim Wilson
.NET Compact Framework MVP
> Thx Tim.
>
[quoted text clipped - 3 lines]
>
> Thx.