WinForm's DataGridView scroll down to disappear

code show as below:

// write  

TH = new new the Thread the Thread (() => {
this.CheckTable (dataFileDB, dataDB, dt); // through multi-threaded to dt (datatable) assigned
this.Invoke (the Action new new (() => {
MessageBox.Show ( " loaded ");
}));
});
th.Start ();
dgvShow.DataSource = dt;

Although the assignment can be able to, but the drop-down box message

TH = new new the Thread the Thread (() => {
this.CheckTable (dataFileDB, dataDB, dt); // through multi-threaded to dt (datatable) assigned
this.Invoke (the Action new new (() => {
MessageBox.Show ( " loaded ");

dt = dgvShow.DataSource;
}));
});
th.Start ();
or the following wording:

TH = new new the Thread the Thread (() => {
this.CheckTable (dataFileDB, dataDB, dt); // through multi-threaded to dt (datatable) assigned
this.Invoke (the Action new new (() => {
MessageBox.Show ( " loaded ");

dgvShow.DataSource=null;

dgvShow.DataSource = dt;
}));
});
th.Start();

dgvShow.DataSource = dt;

Cause of the problem: As DataGridView main thread is created in the sub-thread data binding is to be submitted back to the main thread

Guess you like

Origin www.cnblogs.com/wwr01/p/12518359.html