User interface 用户控件表面上的移动控件不工作

User interface 用户控件表面上的移动控件不工作,user-interface,user-controls,controls,User Interface,User Controls,Controls,我已经建立了一个用户控件,它有一个面板,组合框和标签。在设计时,我可以完美地移动组合框和标签,但如果我移除面板并将组合框和标签直接放置在用户控件表面上,我就不能在设计时移动它们(也不能将新控件拖到用户控件上)。我已经包括了有效的代码。要看到它不工作,只需拆下面板。任何帮助都将非常感谢,在这方面工作了很长时间,没有解决方案 要创建用户控件,只需创建一个名为DBTest的新用户控件,在其上放置一个名为panPrimary的面板并将停靠设置为fill,在面板上放置一个名为cboPrimary的组合框,

我已经建立了一个用户控件,它有一个面板,组合框和标签。在设计时,我可以完美地移动组合框和标签,但如果我移除面板并将组合框和标签直接放置在用户控件表面上,我就不能在设计时移动它们(也不能将新控件拖到用户控件上)。我已经包括了有效的代码。要看到它不工作,只需拆下面板。任何帮助都将非常感谢,在这方面工作了很长时间,没有解决方案

要创建用户控件,只需创建一个名为DBTest的新用户控件,在其上放置一个名为panPrimary的面板并将停靠设置为fill,在面板上放置一个名为cboPrimary的组合框,在标签上放置一个名为lblPrimary的标签

公共类DPT测试

Private Sub Setup_ParentChanged(sender As Object, e As EventArgs) Handles Me.ParentChanged

    If Me.Parent IsNot Nothing Then

        Me.BorderStyle = BorderStyle.None

        TypeDescriptor.AddAttributes(Me.cboPrimary, New DesignerAttribute(GetType(DPTestItemDesigner)))
        TypeDescriptor.AddAttributes(Me.lblPrimary, New DesignerAttribute(GetType(DPTestItemDesigner)))
        TypeDescriptor.AddAttributes(Me.panPrimary, New DesignerAttribute(GetType(DPTestItemDesigner)))

    End If

End Sub
#区域“自定义设计器属性”

<DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
Public ReadOnly Property PadLabel As LA.Core.Label
    Get
        Return Me.lblPrimary
    End Get
End Property

<DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
Public ReadOnly Property PadCombo As LA.Core.ComboBox
    Get
        Return Me.cboPrimary
    End Get
End Property

<DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
Public ReadOnly Property PadPanel As LA.Core.Panel
    Get
        Return Me.panPrimary
    End Get
End Property
Imports System.Drawing.Design
Public Class DPTestDesigner

    Inherits ParentControlDesigner

    Public Overrides Sub Initialize(ByVal component As IComponent)

        MyBase.Initialize(component)

        Dim DP As DPTest = CType(Me.Control, DPTest)

        Me.EnableDesignMode(DP.PadCombo, DP.PadCombo.Name)
        Me.EnableDesignMode(DP.PadLabel, DP.PadLabel.Name)
        Me.EnableDesignMode(DP.PadPanel, DP.PadPanel.Name)

    End Sub

    Public Overrides Function CanParent(ByVal control As Control) As Boolean
        Return True
    End Function

    Protected Overrides Sub OnDragOver(ByVal de As DragEventArgs)
        de.Effect = DragDropEffects.None
    End Sub


    Protected Overrides Function CreateToolCore(ByVal tool As ToolboxItem, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal hasLocation As Boolean, ByVal hasSize As Boolean) As IComponent()
        Return Nothing
    End Function


End Class

Public Class DPTestItemDesigner

    Inherits ParentControlDesigner

    Public Overrides ReadOnly Property SelectionRules As SelectionRules
        Get
            Dim SRules As SelectionRules = MyBase.SelectionRules
            SRules = SRules 'And SelectionRules.auto
            Return SRules
        End Get
    End Property

    Protected Overrides Sub PostFilterAttributes(ByVal attributes As IDictionary)
        MyBase.PostFilterAttributes(attributes)
        attributes(GetType(DockingAttribute)) = New DockingAttribute(DockingBehavior.Never)
    End Sub


    Protected Overrides Sub PostFilterProperties(ByVal properties As IDictionary)

        MyBase.PostFilterProperties(properties)

        Dim propertiesToRemove = New String() {"AutoSize", "Dock", "Anchor", "Size", "Location", "Width", "Height", "MinimumSize", "MaximumSize", "AutoSize", "AutoSizeMode", "Visible", "Enabled"}

        For Each item In propertiesToRemove
            If properties.Contains(item) Then properties(item) = TypeDescriptor.CreateProperty(Me.Component.[GetType](), CType(properties(item), PropertyDescriptor), New BrowsableAttribute(False))
        Next

    End Sub
End Class