Check if form is Opened

前端 未结 8 1368
陌清茗
陌清茗 2020-12-30 23:56

I give this question for more knowledge. How can I know if the form is Opened in my application or not, in order not to open it again I mean not to create an instance of the

8条回答
  •  隐瞒了意图╮
    2020-12-31 00:17

    As an extension of the answers given (thank you, all), here's a simple way to activate or show:

    Dim frmCollection = System.Windows.Forms.Application.OpenForms
    If frmCollection.OfType(Of Form2).Any Then
        frmCollection.Item("Form2").Activate()
    Else
        Dim newForm2 = New Form2
        newForm2.Show()
    End If
    

提交回复
热议问题