optimize updates to DataTable bound to DataGridView

后端 未结 7 1213
执念已碎
执念已碎 2021-02-14 19:27

I have a Form in my application that displays some data. When I first show the Form, I load some data into a DataTable then bind the DataTable to a DataGridView. I also start an

7条回答
  •  甜味超标
    2021-02-14 19:58

    I find the solution by Ravi LVS on codeproject works well:

    BindingSource bs = new BindingSource();
    DataTable dt = new DataTable();
    
    bs.DataSource = dt;
    bs.SuspendBinding();
    bs.RaiseListChangedEvents = false; 
    bs.Filter = "1=0"; 
    dt.BeginLoadData(); 
    
    //== some modification on data table
    
    dt.EndLoadData();
    bs.RaiseListChangedEvents = true;
    bs.Filter = "";
    

    Link to original page: http://www.codeproject.com/Tips/55730/Achieve-performance-while-updating-a-datatable-bou

提交回复
热议问题