Popular datagrid with threading

Asked

Viewed 425 times

3

I am contracting a Windows Form application. I am not getting popular my datagrid with a threading, appears the following error:

"Invalid threaded operation: control accessed datagrid of a thread in which it is created

  • Facilitate help, enter the code. See also: http://answall.com/tour

1 answer

1

A screen element UI(control), in Winforms and WPF do not allow to be accessed by other threads or multiple threads.

The UI element can only be accessed by the thread that was created on it.

What you can do is use delegates...

Invoke(new Action(() =>
{
     if (dataGridView1.CurrentCell.RowIndex < dataGridView1.RowCount )
     {
          dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Selected = false;
          dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex + 1].Selected = true;
     }
}));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.