G
Guest
I've been having a problem on trying add a tab page that are created on non
UI thread to a tab control. I understand that we need to use control.invoke
to invoke the execution on thread that created the control. The code is
working if I simply change a text box text, but not when I adding a tab page.
The exception that I got is "Control.invoke() must be used to interact with
controls created on a separate thread". Here is piece of the code.
Private Delegate Sub AddTabPageDelegate(ByVal tabPage As TabPage)
Private Sub FinishedPopulatingTabPage(ByVal tabPage As
System.Windows.Forms.TabPage) Handles Me.FinishedPopulatingTabPage
If _activeForm.TabControl1.InvokeRequired Then
_activeForm.Invoke(New AddTabPageDelegate(AddressOf AddTabPage),
New Object() {tabPage})
End If
End Sub
Private Sub AddTabPage(ByVal tabPage As TabPage)
_activeForm.TabControl1.TabPages.Add(tabPage)
'_activeForm.Label1.Text = "hello" & tabPage.Text
End Sub
Looks like there is a bug in the tabControl.tabPages.Add(). Any thoughts?
Thanks heaps
UI thread to a tab control. I understand that we need to use control.invoke
to invoke the execution on thread that created the control. The code is
working if I simply change a text box text, but not when I adding a tab page.
The exception that I got is "Control.invoke() must be used to interact with
controls created on a separate thread". Here is piece of the code.
Private Delegate Sub AddTabPageDelegate(ByVal tabPage As TabPage)
Private Sub FinishedPopulatingTabPage(ByVal tabPage As
System.Windows.Forms.TabPage) Handles Me.FinishedPopulatingTabPage
If _activeForm.TabControl1.InvokeRequired Then
_activeForm.Invoke(New AddTabPageDelegate(AddressOf AddTabPage),
New Object() {tabPage})
End If
End Sub
Private Sub AddTabPage(ByVal tabPage As TabPage)
_activeForm.TabControl1.TabPages.Add(tabPage)
'_activeForm.Label1.Text = "hello" & tabPage.Text
End Sub
Looks like there is a bug in the tabControl.tabPages.Add(). Any thoughts?
Thanks heaps