You need to implement a Designer for your usercontrol and create the panel
in it's OnSetComponentDefaults() method.
Here's a basic example in VB.
note: you need to add a reference to System.Design.dll.
\\\
Imports System.ComponentModel
Imports System.ComponentModel.Design
<Designer(GetType(MyDesigner))> _
Public Class MyUserControl
Inherits System.Windows.Forms.UserControl
'Your code here
End Class
Friend Class MyDesigner
Inherits System.Windows.Forms.Design.ControlDesigner
Public ReadOnly Property DesignerHost() As IDesignerHost
Get
Return DirectCast(GetService(GetType(IDesignerHost)), _
IDesignerHost)
End Get
End Property
Public ReadOnly Property HostControl() As Control
Get
Return Me.Control
End Get
End Property
Public Overrides Sub OnSetComponentDefaults()
Dim p As Panel = DirectCast(Me.DesignerHost.CreateComponent _
(GetType(Panel)), Panel)
p.Location = New Point(10, 40)
p.Size = New Size(HostControl.Width - 20, HostControl.Height - 50)
p.Anchor = AnchorStyles.Left Or AnchorStyles.Top Or _
AnchorStyles.Right Or AnchorStyles.Bottom
HostControl.Controls.Add(p)
End Sub
End Class
///
--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
<to********@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I'm trying to build a custom control that includes a panel control on
it. However, in design-time when I drag a new control (e.g. a textbox,
etc) into the panel, it's not added in the panel--just the overall
control.
* I do not want the entire user control to be a panel/container
control. I just want the panel part of it to work as expected.
Any suggestions?
thanks,
Todd