Improved question
=============
How do I simply display a DataTable within a DataGridView without binding the former to the later (using DataSource or so)?
Thanks!
Original question
============
Hi,
I've a DataGridView (say dgv) with the DataSource property set to a DataTable (say dt). 'dt' keeps getting updated asynchronously from some other sources/actions. As and when 'dt' gets updated, CLR triggers for the 'dgv' to also get updated. The problem is, if the 'dt' updates are very frequent, then it slows down the GUI containing 'dgv' because of the DataSource binding of the 'dgv' to 'dt', and even sometimes makes it hang.
Hence, I want to either control the frequency of the 'dgv' updates, or better, I'd prefer the user of the GUI to manually ask for the updated display of the 'dgv' pertaining to any intermittent changes in the 'dt'. I can do this by providing a button just for this purpose. Also, between any two subsequent refreshes of the 'dgv', I'd prefer that the 'dgv' keeps displaying the previous refreshed data from 'dt'. That's to say I won't like to write,
private void button_Click(...)
{
dgv.DataSource = null;
// or, dgv.DataSource = typeof(DataTable), for retaining the column structure, right?
dgv.DataSource = dt;
}
because then, between two subsequent refreshes 'dgv' will be shown as empty.
Any suggestions for achieving this?
Thanks!