本文整理匯總了VB.NET中Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OpenForms屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET WindowsFormsApplicationBase.OpenForms屬性的具體用法?VB.NET WindowsFormsApplicationBase.OpenForms怎麽用?VB.NET WindowsFormsApplicationBase.OpenForms使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase
的用法示例。
在下文中一共展示了WindowsFormsApplicationBase.OpenForms屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: GetOpenFormTitles
Private Sub GetOpenFormTitles()
Dim formTitles As New Collection
Try
For Each f As Form In My.Application.OpenForms
If Not f.InvokeRequired Then
' Can access the form directly.
formTitles.Add(f.Text)
End If
Next
Catch ex As Exception
formTitles.Add("Error: " & ex.Message)
End Try
Form1.ListBox1.DataSource = formTitles
End Sub
開發者ID:VB.NET開發者,項目名稱:Microsoft.VisualBasic.ApplicationServices,代碼行數:16,代碼來源:WindowsFormsApplicationBase.OpenForms
示例2: GetOpenFormTitles
Private Sub GetOpenFormTitles()
Dim formTitles As New Collection
Try
For Each f As Form In My.Application.OpenForms
' Use a thread-safe method to get all form titles.
formTitles.Add(GetFormTitle(f))
Next
Catch ex As Exception
formTitles.Add("Error: " & ex.Message)
End Try
Form1.ListBox1.DataSource = formTitles
End Sub
Private Delegate Function GetFormTitleDelegate(f As Form) As String
Private Function GetFormTitle(f As Form) As String
' Check if the form can be accessed from the current thread.
If Not f.InvokeRequired Then
' Access the form directly.
Return f.Text
Else
' Marshal to the thread that owns the form.
Dim del As GetFormTitleDelegate = AddressOf GetFormTitle
Dim param As Object() = {f}
Dim result As System.IAsyncResult = f.BeginInvoke(del, param)
' Give the form's thread a chance process function.
System.Threading.Thread.Sleep(10)
' Check the result.
If result.IsCompleted Then
' Get the function's return value.
Return "Different thread: " & f.EndInvoke(result).ToString
Else
Return "Unresponsive thread"
End If
End If
End Function
開發者ID:VB.NET開發者,項目名稱:Microsoft.VisualBasic.ApplicationServices,代碼行數:37,代碼來源:WindowsFormsApplicationBase.OpenForms