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 / .NET Framework / New Users / July 2005

Tip: Looking for answers? Try searching our database.

Custom control container behavior in designer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
William Sullivan - 07 Jul 2005 16:01 GMT
Hey, created a custom control that includes a panel.  I want to use the panel
as a container for other controls I drag into the custom control in designer.
I can't seem to find any information on how to do this.  I've extended
UserControl and SetStyle containercontrol to true, but this doesn't work.  I
think I'll have to trap for drag/drop events, test to see if I'm in the
design environment, cast the drag/drop object to a control and then stick it
in the panel.  I'm just hoping that there is an easier way....
Sean Hederman - 07 Jul 2005 22:10 GMT
> Hey, created a custom control that includes a panel.  I want to use the
> panel
[quoted text clipped - 7 lines]
> it
> in the panel.  I'm just hoping that there is an easier way....

Modify your control to inherit from ContainerControl rather than
UserControl. This will allow it to automatically accept controls dropped
into it. I don't know of any ways of controlling where sub-controls would
exist within your container control. One approach might be to intercept
ControlAdded events and move the controls into your Panel when a new control
arrives. Needless to say you should only hook this up after you've added all
your "internal" controls. You might need some other plumbing to keep the
developer from getting the controls out of your Panel into the actual
control.

One downside of inheriting from ContainerControl is that you lose the funky
UI for the UserControl. What I do is design my control the way I want it and
then change the inheritance away from UserControl. Any time I want to make
changes, I change it back.
William Sullivan - 08 Jul 2005 13:48 GMT
Aha!  I knew there was an easier way!  Losing the designer didn't matter, as
it sucked anyhow.  I had all my rendering in a user paint event, which didn't
show up at all in the designer...

> > Hey, created a custom control that includes a panel.  I want to use the
> > panel
[quoted text clipped - 22 lines]
> then change the inheritance away from UserControl. Any time I want to make
> changes, I change it back.

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.