Hello,
I am using an UltraGrid with virtual mode; the CellDataRequested event handler provides cell data from a data collection. The data in the collection are updated by a background thread. When the grid needs to refresh the follow statements are used:
_ultraDataSource.Rows.SetCount(_displayedViewRecords.Count);_ultraDataSource.ResetCachedValues();_ultraGrid.Rows.Refresh(RefreshRow.FireInitializeRow, true);
I noticed that most objects used within the grid are recreated: One instance of each following class is created for grid:
Infragistics.Win.UltraWinGrid.DataAreaUIElementInfragistics.Win.UltraWinGrid.UltraGridUIElementInfragistics.Win.UltraWinGrid.RowColRegionIntersectionUIElementInfragistics.Win.UltraWinGrid.RowSelectorHeaderUIElement
One instance of each following class is created for each row:
Infragistics.Win.UltraWinGrid.RowUIElementInfragistics.Win.UltraWinGrid.RowSelectorUIElementInfragistics.Win.UltraWinGrid.RowCellAreaUIElement
One instance of each following class is created for each column:
Infragistics.Win.UltraWinGrid.BandHeadersUIElementInfragistics.Win.UltraWinGrid.HeaderUIElementInfragistics.Win.TextUIElement
One instance of three or more classes is created for each cell.
I thought all the objects within the grid would be reused as much as possible. The data in my data collection are constantly updated and the grid performance is affected by the recreation of these objects within the grid. I am not sure if I have done something wrong.Could someone point me in the right direction please?
Thanks,Shaolin
Hello Shaolin,
This is expected behavior. Each time a cell value changes the related CellUIElement invalidates and repaints. Actually everything you see on the screen is drawn via hierarchical structure of UIElements. This is a core concept in most of Infragistics Controls for Windows Form. You may follow the next link to our online documentation to find more information about our Presentation Layer Framework http://help.infragistics.com/Doc/WinForms/current/CLR4.0/?page=Win_Presentation_Layer_Framework_PLF.html.
One thing you may change in your code is to call Refresh of the grid rows with RefreshRow parameter set to ReloadData like this:
this.ultraGrid1.Rows.Refresh(RefreshRow.ReloadData, true);
This way you will not force the grid to reinitialize all its rows again.
Please tell me exactly what your issue is? Do you face some bad performance? How big your data is? How much rows and columns your grid consist of? Can you send me a sample reproducing this behavior?
Looking forward to your reply.
Hi Milko,
Thanks for your response!
I am much surprised and puzzled by this logic. I do not see any issue with how the data are rendered by related UIElement objects. I do not understand those UIElement objects are not reused. When the data shown in a grid needs refreshing, why are the grid column header UIElement objects needed to be recreated or refreshed? Each time when I did grid row navigation by clicking on up or down scrollbar arrow, I saw grid column header UIElement objects were recreated.
We have grids with thousands of visible cells (5,000 easily); and the data source could have tens or hundreds of thousands rows and possibly hundreds columns. The data source get constant updates (multiple times per second). I estimate at lease 50,000 UIElement objects created and garbage collected each second, which will definitely affect the grid performance, both data rendering and navigation.
Any suggestion is greatly appreciated!