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 / Design Time / July 2004

Tip: Looking for answers? Try searching our database.

User Control Constituents As Containers?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mario T. Lanza - 30 Jul 2004 00:21 GMT
I am designing a user control that is made up of several constituent
controls (Panels to be precise).  Basically, my user control is made
up of 4 Panels that I am using to define a very specific layout.  The
goal is to add this "Layout Control" onto a form and then to drop
certain controls directly into the different Panels (for docking or
anchoring) during design time.  Unfortunately, when a control is
dropped onto my Layout Control, it doesn't properly dock it on the
immediately underlying Panel.  It docks the new control underneath the
Panels onto the user control area itself thus creating a secondary
visibility issue.

I have read several related posts on Google Groups and information on
Microsoft's website (under MSDN) regarding creating Designers to
support the design time implementation of user controls.  I am not
looking for a reference to more documentation on the issue; I have
been down that road and am still unable to produce the desired result.
I realize I could purchase a book on creating .NET controls from
Amazon and read it in its entirety, but I am hoping for a break here.

Any suggestions?  Better yet, any working code snippets that will help
me accomplish this?

Your help regarding this would be much appreciated.

Mario T. Lanza
Clarity Information Architecture, Inc.
Andy Becker - 30 Jul 2004 17:13 GMT
> Unfortunately, when a control is dropped onto my Layout Control, it
> doesn't properly dock it on the immediately underlying Panel.

It was a while ago, but I remember not finding too much information about
this either.  I did end up with a solution which works for me, though.  As
you might imagine, you need to inherit from Panel and create your own panel.
The key was in the designer, inheriting from ParentControlDesigner (sorry if
VB.NET is not your "native" language):

<Designer(GetType(MyPanel.PanelDesigner))>
... for the inherited Panel class definition, and

Friend Class PanelDesigner
   Inherits System.Windows.Forms.Design.ParentControlDesigner

   Public Overloads Overrides Sub OnSetComponentDefaults()
       MyBase.OnSetComponentDefaults()
       MyBase.Control.Anchor = AnchorStyles.Top Or AnchorStyles.Left Or
AnchorStyles.Bottom Or AnchorStyles.Right
       ' other stuff you may want to do...
   End Sub
End Class

for the designer.  This solved my parenting issues.  I hope it saves you
some time and hair loss.  :-)

Best Regards,

Andy

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.