我想检测一个窗口窗体是否打开,如果要打开,那么我想将其放在前面而不是再次打开。
我知道我需要一个表单集合,但是我想知道是否有一个内置的表单集合来保存VB.NET中的所有表单,或者我需要实现自己的表单集合。
谢谢。
最佳答案
您可以尝试:
'Pass the form object (you could also use string as the
'parameter and replace the if condition to: "If form.Name.Equals(targetForm) Then")
Public Sub BringToFront(ByVal targetForm As Form)
Dim form As Form
For Each form In Application.OpenForms()
If form Is targetForm Then
form.BringToFront()
Exit For
End If
Next
End Sub
如果需要将特定的表单放在前面(仅在已加载的情况下),请调用此子程序,如下所示:
BringToFront(targetformobject)
关于.net - VB.NET中的FormCollection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2406070/