如何获取表单克隆变量?

时间:2017-12-02 23:26:19

标签: vb.net

Public Sub playbtnclick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles playbutton.Click
    Dim form2clone As New Form2
    form2clone.Tag = selectedpicid
    form2clone.Show()
End Sub


Public Sub labelclick(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim lbl As Label = sender

    For Each frm2 As Form2 In 'How can I find specified form2? 
        If frm2.Tag = searchtag Then
            TextBox1.Text = frm2.justvariable & lbl.Tag
            Exit For
        End If
    Next
End Sub

如何在VB.net中找到指定的form2并获取表单克隆变量?

1 个答案:

答案 0 :(得分:1)

您可以在列表中添加form2,然后遍历该列表。 E.g。

Dim ALForm2 as new list (of Form2)
Dim form2clone As New Form2 
form2clone.Tag = selectedpicid 
form2clone.Show()
ALForm2.Add (form2clone)

然后你可以循环通过ALForm2