克隆我的 Windows 表单自定义控件可以说是可行的,但我看不到克隆

Cloning my Windows forms custom control arguably works, but I can't see the clone

我正在尝试克隆我的 Windows 表单自定义控件。

其中,我有

Public Class UFB
    Implements ICloneable

    ...

    Public Function Clone() As Object Implements ICloneable.Clone
        'Copy this instance's properties.
        Dim oClone As New UFB With {
            .BackColor = Me.BackColor,
            'Another few dozen properties.
            ... }

        'Deep copy of objects in a dictionary (loop).
        ...

        Return oClone
    End Function

    ...
End Class

使用这个的 Windows 表单有一个命令按钮可以克隆。要克隆的对象名为 cFlb.

我是这样使用的:

Public Class FMain
    Dim WithEvents cFlbClone As UFB

    Private Sub Clone()
        cFlbClone = CType(cFlb.Clone, UFB)

        cFlbClone.BackColor = Drawing.Color.Yellow    'Make it distinguishable.
        cFlbClone.Visible = True
        cFlb.Visible = False
    End Sub
End Class

在两个项目中都能很好地编译。

cFlb.Visible = False 上的断点让我检查 cFlb 属性。一切都应有尽有,尤其是深层复制元素。克隆的位置和原来的一样

我唯一的问题是:我没有看到克隆。什么都没有。

我错过了什么?

要使控件可见,它必须父级 到窗体或以窗体作为其 TopLevelControl 的另一个控件。如果任何祖先控件不可见,则主题控件也将不可见。

可以通过设置控件的 Parent Property or adding the control to the parent control's Controls Property.

来完成