Search code examples
c#winformsdatagridviewbindingsource

DataGridView - Load large number of data very slow


I have a form with Datagridview that load data from db to binding source and then set binding source as DataSource of datagrid
I call SuspendBinding() and set RaiseListChangedEvents to false before fill data from db and when data fill call ResumeBinding() and ResetBindings(false) and set RaiseListChangedEvents to true

newPriceListSelectBindingSource.RaiseListChangedEvents = false;
newPriceListSelectBindingSource.SuspendBinding();
newPriceListSelectTableAdapter.Fill(dsOrders.NewPriceListSelect, null, int.Parse(trvCategory.SelectedNode.Name), Convert.ToInt32(numericUpDown1.Value));
newPriceListSelectBindingSource.RaiseListChangedEvents = true;
newPriceListSelectBindingSource.ResumeBinding();
newPriceListSelectBindingSource.ResetBindings(false);

in many windows operating systems when filling data finished, resetbindings(false) call immediately, but in windows server 2008 r2 this method call very very slow (it seem to program hangs).
of course I'm not sure this depends on windows.
data rows is about 80000 rows in 20 columns.
Please help me to solve this problem.


Solution

  • I found the problem
    Problem was for grid column property named DataGridViewColumn.AutoSizeMode because the value of this property for one of column is AllCells and I changed this to DisplayedCells and problem fixed.