Visual Basic:
1
2
3
4
5
6
7
8
9
10
11
12
| Private WithEvents myGrid As New AccountGrid() Private AccountGridThread As New Thread(AddressOf myGrid.FillDataSet) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AccountGridThread.Start() StatusBar1.Text = "Loading accounts..." End Sub Private Sub SquareEventHandler(ByVal DS As DataSet) Handles myGrid.ThreadComplete DataGrid1.SetDataBinding(DS, "Accounts") StatusBar1.Text = "Done loading accounts" End Sub |
Bij
Visual Basic:
1
| DataGrid1.SetDataBinding(DS, "Accounts") |
krijg ik:
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
Additional information: Controls created on one thread cannot be parented to a control on a different thread.
Hou kan ik die DataSet die ik terug krijg toch gebruiken op mijn datagrid?