I have ListBox called lstProductGroups.
On a simple Windows Form, a method called GetGroups gives me string groups selected by the user like Cars, Bikes etc.
public List<string> GetGroups()
{
List<string> prodGroups = (from object item in lstProductGroups.SelectedItems select item.ToString()).ToList();
return prodGroups;
}
But if I try to access same method from another thread I get all items in my list called System.Data.DataRowView.
I even tried it in a foreach loop with BeginInvoke, but the item.ToString() always returns System.Data.DataRowView.
I am new to Winforms with threading. What am I doing wrong?
First declare a delegate:
Change your method like this:
Call your method: