c# - rebuilding columns and adding a new dataset to DataListView -
c# - rebuilding columns and adding a new dataset to DataListView -
so using datalistview variant brightideassoftware c# project.
i utilize buttons alter view of datalistview. when button pressed next executed:
olv.datasource = null; olv.allcolumns = collist; olv.rebuildcolumns(); //fill olv info olv.datasource = dt; the first button creates 1 column , changes view view.tile;.
the sec button creates 4 columns , changes view view.details;.
the new columns shown takes sec info show in list. takes longer when rebuild larger amount of columns.
when run application builds view 4 columns in view.details instantly. when switch first button view sec button view hangs moment.
in debug mode noticed rebuildcolumns() 1 hangs. if leave olv.datasource = dt; out, code after rebuildcolumns() executed immediatly.
can explain me why happening?
thanks
first of not clear me if lists switching between utilize same datatable (i assume that's type of dt object). if source identical needn't add together , remove columns, can set olvcolumn.isvisible. that's faster.
second, setting objectlistview.datasource = null won't remove items list (you need objectlistview.clearobjects that), invalidate internal datasourceadapter.currencymanager block item updates until objectlistview.datasource set again. setting info source add together items list (calls objectlistview.buildlist) might expensive if source large.
in conclusion:
if switch between lists shared datasource then:
foreach (var column in this.datalistview.allcolumns) column.isvisible = true; // phone call when tampering columns this.datalistview.rebuildcolumns(); // if need add/remove items, same philosophy, partial instead of // finish update utilize filtering instead of datasource reset if lists not have mutual datasource , hence columns totally differ, cost have pay, rebuilding columns , items, escape tabcontrol instance. switch between lists without having reset datasource time. should 1 time experience.
c# objectlistview
Comments
Post a Comment