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
680
Exception on CalculateAutoResize
posted

I have a test app for some grid stuff I'm doing. The app has 4 buttons and allows me to bind different types of data to the grid. I can't actually include all the code involved, but the problem appears to be very isolated.

When I call UltraGridColumn.CalculateAutoResize, from time to time (and there doesn't appear to be a rhyme or reason to it), it throws an IndexOutOfRangeException with this call stack:

    at Infragistics.Shared.SparseArray.ValidateIndex(Int32 index)
   at Infragistics.Shared.SparseArray.GetItem(Int32 index, ICreateItemCallback createItemCallback)
   at Infragistics.Win.UltraWinGrid.ScrollCountManagerSparseArray.GetItem(Int32 index, Boolean create)
   at Infragistics.Win.UltraWinGrid.RowsCollection.InternalTraverseRowsHelper(UltraGridBand band, IRowCallback rowCallback, IRowsCollectionCallback rowsCollectionCallback, Boolean recursive, Boolean includeTemplateAddRows)
   at Infragistics.Win.UltraWinGrid.UltraGridColumn.CalculateMaxCellTextWidth(Int32 maxColWidth, RowsCollection rows, Int32 nRows, Int32 maxRowsCollections)
   at Infragistics.Win.UltraWinGrid.UltraGridColumn.PerformAutoResizeHelper(RowsCollection rows, Int32 nRows, Boolean applyWidth, Boolean includeHeader, Boolean includeCells, Int32 maxRowsCollections)
   at Infragistics.Win.UltraWinGrid.UltraGridColumn.PerformAutoResizeHelper(RowsCollection rows, Int32 nRows, Boolean applyWidth, Boolean includeHeader, Boolean includeCells)
   at Infragistics.Win.UltraWinGrid.UltraGridColumn.CalculateAutoResizeWidth(PerformAutoSizeType autoSizeType, Boolean includeHeader)
   at DTC.NTFFV.Utilities.UltraGridBindingExtensions.GridExtensions.HandleColumnAttributes(UltraGrid grid, UltraGridColumn col, Type containedType, UltraGridLayout layout) in C:\DTCDev\NTFFV\Utilities\UltraGridBindingExtensions\Domain\GridExtension.cs:line 529

The code in question is:

int calculatedWidth = col.CalculateAutoResizeWidth(PerformAutoSizeType.AllRowsInBand, true) + 8;

Obviously col is a valid UltraGridColumn. What could I possibly be doing that would cause CalculateAutoResize to throw this exception?

Thanks

Pete 

 

Parents
No Data
Reply
  • 680
    posted

    As an additional note, the resizing is taking place during the CurrencyManager.ListChanged event. That is, I do something along these lines:

    CurrencyManager cm = BindingContext[grid.DataSource, grid.DataMember] as CurrencyManager;
    cm.ListChanged += new ListChangedEventHander(cm_ListChanged);

    then in my cm_ListChanged, I'm looping through all the columns in the grid and performing the autoresize.

    I have created a separate app that just does that and I cannot reproduce the error, but it occurs to me that that might be relevant in diagnosing the issue, since I'm sure the grid is also handling the CurrencyManager.ListChanged event.

Children