Hi mrtn,
>>In terms of the datatable filling process, the fill method is run in a BackgroundWorker and then I run BindingSourceFirms.ResetBindings(False) in the BackgroundWorker Completed event.
This problem is probably caused by filling the DataTable in the secondary thread. Because it affects the ComboBox as a control, it cannot be accessed from a secondary thread. So you need to fill the unbound DataTable in the DoWork event handler, and then bind the data to the RunWorkerCompleted event handler, which is executed on the UI thread.
Here is my test code:
Friend Class SurroundingClass
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
backgroundWorker1.RunWorkerAsync()
comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems
End Sub
Private Sub backgroundWorker1_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
Me.table1TableAdapter.Fill(Me.dataSet1.Table1)
End Sub
Private Sub backgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs)
comboBox1.DataSource = dataSet1.Table1
comboBox1.DisplayMember = "ID"
comboBox1.ValueMember = "ID"
End Sub
End Class
Test result:
>>when I run it in VS but doesn't when the app is run on Windows.
How Could you provide more information to reproduce the situation and what error did you encounter?
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.