我在手动加载表单时添加表单控件:
Me.FieldI = New TextBox()
Me.FieldI.Location = New System.Drawing.Point(50, 10)
Me.FieldI.Name = "FieldI"
Me.FieldI.Size = New System.Drawing.Size(40, 20)
Me.FieldI.TabIndex = 5
Me.Conversion.Controls.Add(Me.FieldI)
[..]
当我关闭表单窗口并重新打开它时,控件仍然存在(带有旧.Text
内容,因为在这种情况下它是一个文本框)。
我想删除在表单关闭事件上加载表单时创建的控件,以防止表单上的元素加倍。
我怎样才能做到这一点?
编辑
表单关闭代码如下所示(仅显示主表单):
Private Sub Form1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.FormClosing
Main.Show()
End Sub