VB.Net克隆控件

时间:2015-10-23 21:04:30

标签: vb.net

这是我在将控件添加到我的groupbox之前用来克隆控件的代码(尝试从我现有的标签lblPriDB克隆):

lbl = New Windows.Forms.Label()

 For Each oPropertyInfo As System.Reflection.PropertyInfo In lbl.GetType().GetProperties()
        If oPropertyInfo.CanWrite Then
          oPropertyInfo.SetValue(lbl, oPropertyInfo.GetValue(lblPriDB, Nothing), Nothing)
        End If    
  Next

 lbl.Name = lbl.Name + iCount.ToString
 grpBox.Controls.Add(lbl)
 lbl.Location = New Point(lblPriDB.Location.X, 250)

for循环中的某些东西冻结了我的UI,而grpBox.Controls.Add(lbl)命令实际上并没有添加标签。我试图解决这个问题,但是有太多属性,任何帮助都会受到赞赏!

0 个答案:

没有答案