SplitContainer UserControl中的Groupbox [英] Groupbox in SplitContainer UserControl

查看:95
本文介绍了SplitContainer UserControl中的Groupbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我的用户控件有问题.
我的用户控件继承自SplitContainer.
现在,我想在两个面板中添加一个组框.
问题是当我这样做时,无法向其中添加控件.
因此,例如,如果将用户控件放在表单上并拖动,则在组框(面板内)上的按钮将被放置在面板上而不是面板上的组框中.这使我的按钮不可见.

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.

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

推荐答案

看看设计嵌套控件 [ ^ ]的确是:- O(无耻的插头).

该代码是C#,但并不复杂,因此希望您能够将其转换为VB.NET.

如果不是这样,那么那里有很多链接将带您到MSDN参考,这些参考当然包含VB代码,或者这些站点的解释足够清楚以使您理解.

祝你好运. :)
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. :)


这篇关于SplitContainer UserControl中的Groupbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆