Link to home
Start Free TrialLog in
Avatar of Kevin Robinson
Kevin Robinson

asked on

Cross-thread operation not valid: Control


I am trying to load a combo box from a web service.  I am doing this through a callback Display lists.  Display lists receives the Lists parameter fine when called. So the web service call itself is working fine.   But when i tries to bind the list to the combo box i get the error  "Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on."  

I have tried re-factoring this in many ways using background workers etc I even tried to create my own custom control who sole purpose was to load this data.  All methods seem to give me the same error.




 
Private WithEvents M_List As New IContact.List

  
Private Sub ctrl_ImportGroups_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.M_List.LoadLists()
End Sub



Public Sub DisplayLists(ByVal Lists As List(Of IContact.List)) Handles M_List.onLoadListsCompleted
        Me.cmbIContactList.DataSource = Lists
        Me.cmbIContactList.ValueMember = "listid"
        Me.cmbIContactList.DisplayMember = "name"
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Naman Goel
Naman Goel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kevin Robinson
Kevin Robinson

ASKER

Great.  Almost had that actully