Groups | Blog | Home
all groups > dotnet windows forms databinding > may 2006 >

dotnet windows forms databinding : [DataGrid, adding multiple Rows to DataTable] How to speed up the process?


Pascalus
5/23/2006 7:10:47 PM
Hi there!

Adding thousands (let's say 100'000) of rows to a DataSet->DataTable in
the way (C++ style):

DataTable *table = dataset->Tables->Item[S"MyTable"];
table->Clear();
for(int i=0; i<num; i++) {
DataRow *newRow = table->NewRow();
newRow->Item["Column1"] = something;
newRow->Item["Column2"] = something;
table->Rows->Add(newRow);
}
table->AcceptChanges();


....is terribly slow because the DataGrid is updating at the same time
(one can see the scrollbox decreasing in size).
Is there a way to make the Datagrid update ONLY when the DataTable is
filled?

Many thanks,
cduffy NO[at]SPAM ideacorporation.com
5/31/2006 10:43:13 AM
[quoted text, click to view]

Don't bind until after the table is filled :-)

Chuck

[quoted text, click to view]
Ryan
6/28/2006 7:47:53 AM
This may be terribly late, over a month, but I had the same problem. It is easily fixed by suspending the layout of the datagrid to which your datatable is bound, then resuming when your table modification is done. Like so:

yourDataGrid.SuspendLayout();

.....modify 'yourDataGrid's dataSource 'table';

yourDataGrid.ResumeLayout();

Ryan
---
AddThis Social Bookmark Button