Using a Panel in the Form Designer

Is there a way to use Panels the same way you use forms in the form designer environment.  What I mean is how do I design a panel (by dragging and dropping controls) and keep it as a separate component in the Solution Explorer.  
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I'm not sure that you can do that (but I could be wrong...wait for more answers from the others).  Why would you choose to use a solo panel, instead of a form?  You can make a form LOOK like a panel, if that's what you're driving towards.
fbk2000Author Commented:
I would like a main panel reference on the main form, and then many panels that can be swapped out by reference based on other decisions.
Hi ZeonFlash,

What you can do is design a few panels on a form and set thier visible property to false, then swap the visbilty when you need to show them.  I also specify the location of the panel so in design mode I can have a big form showing the panel tiled across the form and then in runtime they stack on top of each other.

I don't think you can add them to the solution explorer

That's what I was thinking too awilde2000.  There is another way that you can do it...but it's kinda shady.

You can create the look and feel of your panels, then copy the Initialize code into it's own class (that inherits the Panel class).  Then when you want to create an instance of a custom panel, you can create a new instance of the custom class.  For instance:

Public Class MyPanel1
    Inherits Panel

    Sub New()
    End Sub

    Friend WithEvents TextBox1 As New System.Windows.Forms.TextBox

    Private Sub InitializeComponent()
        Me.Location = New System.Drawing.Point(296, 128)
        Me.Name = "Panel1"
        Me.TabIndex = 0
        Me.BorderStyle = BorderStyle.FixedSingle
        TextBox1.Location = New System.Drawing.Point(8, 8)
        TextBox1.Name = "TextBox1"
        TextBox1.TabIndex = 0
        TextBox1.Text = "TextBox1"


    End Sub
End Class

To add the panel to the form:

    Dim myCustomPanel As MyPanel1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        myCustomPanel = New MyPanel1
    End Sub

Again, this probably isn't recommended (although it does work).  You're going to be creating a layer of complexity that will make it very difficult to edit the panels in the future (since you're removing the placement of the controls into the code)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fbk2000Author Commented:
and yet this is exactly what people are used to if they've ever developed in Java Swing or MFC.  I guess this is the best solution.  I'm probably too reliant on the WYSIWYG aspects of MS development environments anyway.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.