What do i want to do:
I have a thread, inside this thread ill go through a listview with a foreach loop.
And inside that foreach loop i want to edit / update the GUI.
My problem is, i dont know how i can access the items inside the ListView from my thread.
Because ill get all the time the error message that i cannot access the ListView from my thread.
I hope someone can help me, which would be great.
And sorry for my bad english.
Here's some of my code which i tried:
private void Button1_Click(object sender, EventArgs e)
{
Thread t = new Thread(new ThreadStart(DoIt));
t.Start();
}
private void DoIt()
{
foreach (ListViewItem item in ListView1.Items)
{
Label1.Text = item.SubItems[1].Text;
Thread.Sleep(500);
}
}

New Topic/Question
Reply




MultiQuote







|