Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
175
Performance hit when setting cell.ValueList in InitializeRow (or how to suspend repainting?)
posted

I have a bound grid with several columns. One column is a custom drop-down list. Items of list depend on row data (varies from row to row). 

Setup of such column is performed in InitializeRow event by creating ValueList, adding required items (with correct one which corresponds to bound data), and setting this ValueList to required column's cell with cell.ValueList = list. 

When grid is shown for the first time and data (around 1200 rows) is bound, SetDataBinding executes in no time (<0,1s) (it is possible that data is bound while grid is not visible yet).

But, if other data of the same amount is bound to the same grid, SetDataBinding blocks for about 20s.

I've analyzed execution with performance profiler and found that while setting value list to cell - cell.ValueList = list - redraw/invalidation of the grid is invoked which slows down performance:

Infragistics.Win.ControlUIElementBase.VerifyIfElementsChanged(Boolean, Boolean), 
Infragistics.Win.UIElement.VerifyChildElements(Boolean)
Infragistics.Win.UltraWinGrid.UltraGridUIElement.VerifyChildElements(ControlUIElementBase, Boolean)
... etc

If I comment out  cell.ValueList = list; line, grid is bound in milliseconds every time.

Code of setting cell.ValueList is executed in BeginUpdate/EndUpdate of grid.
I've tried several other options (SuspendRowSynchronization, BeginInit, even grid.Visible = false) but with no luck.

I suspect that after data is bound to a grid for the first time or grid is drawn for the first time, any subsequent bindings/redraws are not suspended in the same way? 

Is there any way to suspend all grid repainting/invalidating and invoke them after all cell.ValueList's are set? Or somehow suspend cell.ValueList invalidations?

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi,

    Do I understand correctly that you are using BeginUpdate and EndUpdate inside the InitializeRow event surrounding the code that set the ValueList property on the cell?

    If that's the case, have you tried removing the BeginUpdate/EndUpdate from that event?

    It seems to me that calling these methods inside InitializeRow is a bad idea and will probably slow your application down rather than speed it up.

    Invalidating the grid (or any portion of it) is a very fast operation. So causing an invalidate inside InitializeRow should not cause a problem.

    But once you call EndUpdate, you are forcing the grid to paint, which is much more expensive and that could certainly slow things down.

    BeginUpdate and EndUpdate are intended for use when you are performing a lot of operations all at once. So using them inside InitializeRow doesn't make a lot of sense and could actually cause problems.

    Also.... Assigning a ValueList to each cell in the column is probably not a good idea, anyway. You might want to check out this article which explains a better way to achieve different lists on each row.

    Creating a dropdown list in a grid cell whose list values are dependent on another cell - Windows Forms - Infragistics Community

Children