Check if form is Opened

前端 未结 8 1414
陌清茗
陌清茗 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:26

    You can try it like this:

     Imports System.Linq ' need to add 
    
    
    If Application.OpenForms().OfType(Of Form2).Any Then
      MessageBox.Show("Opened")
    Else
      Dim f2 As New Form2
      f2.Text = "form2"
      f2.Show()
    End If
    

提交回复
热议问题