UserControl控制容器vb.net

时间:2018-10-15 05:33:09

标签: vb.net user-controls

我有一个用户控件,其标签停靠在顶部,面板停靠为填充,该面板在标签前面:

user control image

我正在使用Windows.Forms.Design.ParentControlDesigner作为设计器,以使用户控件充当控件容器:

 Public Class UserControlDesigner
    Inherits Windows.Forms.Design.ParentControlDesigner
    Public Overrides Sub Initialize(component As System.ComponentModel.IComponent)
        MyBase.Initialize(component)
        If (Me.Control Is GetType(SPnLabelPanel)) Then
            Me.EnableDesignMode(CType(Me.Control, SPnLabelPanel).DropZone, "DropZone")
        End If
    End Sub
End Class

我有一个DropZone属性,该属性返回panel

<Designer(GetType(UserControlDesigner))>
Public Class SPnLabelPanel
            ...

        <Category("Appearance")>
        <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
        Public ReadOnly Property DropZone As Panel
            Get
                Return mainPanel
            End Get
        End Property
End Class 

在设计时一切正常,并将控件添加到用户控件中

desin-time

但是在运行时,控件的移动与标签Height的大小相同

run-time

我的问题在哪里?我应该添加一些属性来实现这一点吗?

0 个答案:

没有答案