0
Public Sub New(ByVal oldC As Control)
    Dim FQTN As String = oldC.GetType.FullName
    Dim t As Type = Type.GetType(FQTN)
    Dim newC As Object = Activator.CreateInstance(t)
End Sub

FQTN正在返回正确的类型名称,但是tNothing. 例如,FQTN = System.Windows.Forms.Panel.

4

1 回答 1

1

摆脱FQTN.

这适用于您正在寻找的面板示例

Public Sub New(ByVal oldC As Control)
    Dim t As Type = oldC.GetType()
    Dim newC As Object = Activator.CreateInstance(t)
End Sub

此外,这是Type.GetType("namespace.abClassName") 的副本返回 null

于 2016-01-15T19:39:34.163 回答