开发者

find instances of a form in vb 2008

开发者 https://www.devze.com 2023-02-05 14:59 出处:网络
Dim f as new frmNameHere开发者_运维技巧 f.show() How do I find all instances of frmNameHere created using the above code?For example:
Dim f as new frmNameHere  开发者_运维技巧
f.show()

How do I find all instances of frmNameHere created using the above code?


For example:

For i As Int32 = 1 To 10
   Dim frm As New frmNameHere()
   frm.Show()
Next
Dim openForms = Application.OpenForms.OfType(Of frmNameHere)()
While openForms.Any()
   openForms.First.Close()
End While

Works also without linq, but then you have to iterate through all OpenForms:

Dim forms As FormCollection = Application.OpenForms
For Each form As Form In forms
   If TypeOf form Is frmNameHere Then
      'do something with your frmNameHere-Form'
   End If
Next
0

精彩评论

暂无评论...
验证码 换一张
取 消