DotNet Academy of Rajesh Rolen

Solutions by Rajesh Rolen

Cross-thread operation not valid: Control 'ListBox1' accessed from a thread other than the thread it was created on

This error comes when you tries to add items in list box (or any other control) in thread (or from the function which is being used by thread).

Below is solution:

Private Delegate Sub stringDelegate(ByVal s As String)
Private Sub AddItem(ByVal s As String)
If ListBox1.InvokeRequired Then
Dim sd As New stringDelegate(AddressOf AddItem)
Me.Invoke(sd, New Object() {s})
Else
ListBox1.Items.Add(s)
End If
End Sub


now just pass your value in "AddItem()" and it will be added in listbox.

8 comments:

Anonymous January 9, 2010 at 3:55 AM  

Keep posting stuff like this i really like it

Anonymous March 1, 2010 at 12:11 PM  

Hi folks... I am brand new here but I can't wait to start having/getting several good chats along with you all! I just figured i would introduce myself to you all so hello!

Anonymous March 12, 2010 at 1:39 PM  

Hi,

I just came across to dotnetacademy.blogspot.com from google and I find dotnetacademy.blogspot.com very interesting.
I wish, can make lot's of new friend here :)

Anonymous March 18, 2010 at 4:43 PM  

clips lesbians making out

Anonymous April 9, 2010 at 12:49 AM  

I totally support that! Continue that way!

Anonymous April 20, 2010 at 6:40 PM  

Hi Everyone! I hope all is well and I look forward to be a great contributor to this community. Feel free to introduce yourself so I can get to know you better...

Anonymous April 26, 2010 at 6:34 PM  

проститутки индивидуалки краснодара спб академическая проститутки проститутки на дорогах москвы дешовые проститутки питера шлюха com

Anonymous July 25, 2010 at 3:02 AM  

You were not mistaken, truly

Post a Comment

About this blog

Blog Archive

My Blog List

Advertise On This Site

Site Info

Advertise on this Site

To advertise on this site please mail on RajeshRolen@gmail.com

Information Source

About

Pages

Dot Net Academy

Advertis in This Area of Site

Powered by Blogger.

Followers

Blog Archive

Search This Blog