Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I am having a problem with a user control.
My user control inherits from SplitContainer.
Now I want to add a groupbox to both panels.
The problem is that when I do this I can't add controls to it.
So if I put my user control on a form and I drag, for example, a button on my groupbox (inside a panel) my button will be placed on the panel and not in the groupbox on the panel. This makes my button not visible.

VB
Public Class MySplitter
   Inherits SplitContainer

Public m_Groupbox1 As GroupBox

   Public Sub New()
      MyBase.New()

      ' This call is required by the Windows Form Designer.
      InitializeComponent()

      ' Add any initialization after the InitializeComponent() call.
      InitGB

   End Sub

   Private Sub InitGB()
      m_Groupbox1 = New GroupBox
      m_Groupbox1.Name = "GroupBox1"
      m_Groupbox1.Text = "Hello"
      m_Groupbox1.Dock = DockStyle.Fill
      Me.Panel1.Controls.Add(m_Groupbox1)
End Sub


Any suggestions on how I would make this work?
Thanks
Posted

1 solution

Take a look at Designing Nested Controls[^] by yours truly :-O (Shameless plug).

The code is C# but is not complicated, so hopefully you will be able to translate to VB.NET.

If not, there are lots of links in there that will take you to MSDN references that, of course, contain VB code, or sites where the explanation is clear enough for you to understand.

Good luck. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900