Check if form is Opened

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

    For more simplicity you may create a public static bool variable which will tell whether the form is opened or not. On form load event assign 'true' and on closed event assign 'false' value.

    0 讨论(0)
  • 2020-12-31 00:39

    Hate to be a kill joy but some day some one is going to try and understand your code.

    Dim frm as New frmDontknow
    Dim frmCollection = System.Windows.Forms.Application.OpenForms
    For i As Int16 = 0I To frmCollection.Count - 1I
      If frmCollection.Item(i).Name = frm.Name Then
          frmCollection.Item(i).Activate()
          Exit Sub
      End If
    Next i
    

    Then do the show etc as required?

    0 讨论(0)
提交回复
热议问题