c# - rebuilding columns and adding a new dataset to DataListView -


Then I am using DataListView version from BrightEdeasSoftware for my C # project.

I use the buttons to change the view of DataListView when a button is pressed, it is executed:

  olv.DataSource = null; Olv.All Columns = colist; Olv.RebuildColumns (); // fill the OLV with the data OLV. DataSource = dt;  

The first button creates 1 column and changes the view to see. Tile ;.

The second button creates 4 columns and changes to view the scene. description ;.

New columns are shown immediately but for the data shown in the list it takes about each other. When I make a large number of columns again, it takes longer.

When I run my application, it creates a visual with 4 columns in the scene. Details immediately only when I switch from the first button view to the second button view, it is hanging for a moment.

In the debug mode I saw that the redefined column () is the one that is hanging. But if I leave the olv. Datasource = dt;

Why is this happening?

Thanks

First of all it is not clear to me if you list the same Switching between the use of code, I think your DT object). If the source is the same then you do not need to add and remove columns, you can set up OLVColumn.iswisible . It's fast

Second, the setting will not delete items from the ObjectListView.DataSource = null list (you need ObjectListView.ClearObjects for this), but What this will do is internal DataSourceAdapter.CurrencyManager will be canceled, which is specially re-set to ObjectListView.DataSource until any item updates Will block. Setting up a data source will add items to your list (call ObjectListView.BuildList ) which can be expensive, your source is large.

In Closing:

If you switch between lists with only the shared data source:

  foreach (in the var.d column This.dataListView.AllColumns) column Virtual = true; // Call it after tampering with this column only This data. LISTView.RebuildColumns (); // If you need to add / delete items, then instead of partial data source processing, instead of partial data usage, instead of filtering partially  

if the list contains a general data source And therefore the column is completely different, so this is a price you have to pay, columns and items will need to be rebuilt, but for example you can avoid TabControl all the time Datasource reset Switch between lists without having to do. It should be experienced once.


Comments