有沒有人在這裏看到我的錯誤?檢查是否有任何對話框打開
我無法識別表單在我的應用中是否顯示爲對話框。
Public Class Form1
Private m As Form2
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
Me.Text = DateTime.Now.ToLongTimeString & " " & IsAnyDialogShown()
End Sub
Public Function IsAnyDialogShown() As Boolean
For Each f As Form In Me.OwnedForms
If f.Owner Is Me Then
Return True
End If
Next
End Function
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
m = New Form2
m.ShowDialog()
End Sub
End Class
我想知道是否有任何對話框顯示在我的應用程序中,而不僅僅是「我」。但是我沒有找到類似於「對於每個f都是app.forms中的表單」 – tmighty