Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / February 2006

Tip: Looking for answers? Try searching our database.

Why is a custom control always wrapped by a user control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Buddhist.CHinA@gmail.com - 26 Feb 2006 06:11 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.