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