Mark Mark - 1 year ago 176
C# Question

Slow to set DataGridView DataSource to DataTable in C#

I have a DataTable, fully populated, which I want to set to a DatagridView:

gdv.DataSource = dt;

However, this is painfully slow. The filling of the DataTable is very quick, but just this one line above takes ages. Is there any way to speed this up or perform it in another thread?

There is no interaction after this point. Just the simple statement above!


Answer Source

Check the formatting options, especially the Fill -related properties. Adjusting columnwidths for all rows involves a lot of calculation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download