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
430
Exception in ScrollCountInternal for grouped grid
posted

Hi,

I'm getting an exception from time to time in a grouped UltraWinGrid. The call stack is the following

System.ArgumentException: An item with the same key has already been added.

   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)

   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)

   at Infragistics.Win.UltraWinGrid.UltraGridRow.get_ScrollCountInternal()

   at Infragistics.Win.UltraWinGrid.UltraGridRow.Infragistics.Shared.ISparseArrayMultiItem.get_ScrollCount()

   at Infragistics.Shared.SparseArray.EnsureScrollCountCalculatedHelper(NodeExtended n)

   at Infragistics.Shared.SparseArray.EnsureScrollCountCalculated()

   at Infragistics.Shared.SparseArray.GetVisibleCount()

   at Infragistics.Win.UltraWinGrid.RowsCollection.GetVisibleRowCount(Boolean includeSpecialRows)

   at Infragistics.Win.UltraWinGrid.RowsCollection.HasAnyVisibleRows()

   at Infragistics.Win.UltraWinGrid.UltraGridGroupByRow.HasAnyVisibleChildRows()

   at Infragistics.Win.UltraWinGrid.UltraGridGroupByRow.get_Hidden()

   at Infragistics.Win.UltraWinGrid.UltraGridRow.get_HiddenInternal()

   at Infragistics.Win.UltraWinGrid.UltraGridRow.get_ScrollCountInternal()

   at Infragistics.Win.UltraWinGrid.UltraGridRow.Infragistics.Shared.ISparseArrayMultiItem.get_ScrollCount()

   at Infragistics.Shared.SparseArray.EnsureScrollCountCalculatedHelper(NodeExtended n)

   at Infragistics.Shared.SparseArray.EnsureScrollCountCalculated()

   at Infragistics.Shared.SparseArray.GetVisibleCount()

   at Infragistics.Win.UltraWinGrid.RowsCollection.GetVisibleRowCount(Boolean includeSpecialRows)

   at Infragistics.Win.UltraWinGrid.RowsCollection.HasAnyVisibleRows()

   at Infragistics.Win.UltraWinGrid.UltraGridGroupByRow.HasAnyVisibleChildRows()

   at Infragistics.Win.UltraWinGrid.UltraGridGroupByRow.get_Hidden()

   at Infragistics.Win.UltraWinGrid.UltraGridRow.get_HiddenInternal()

   at Infragistics.Win.UltraWinGrid.UltraGridRow.get_HiddenResolved()

   at Infragistics.Win.UltraWinGrid.RowScrollRegion.get_FirstRow()

   at Infragistics.Win.UltraWinGrid.RowScrollRegion.GetMaxScrollPosition(Boolean scrollToFill)

   at Infragistics.Win.UltraWinGrid.RowScrollRegion.EnsureScrollRegionFilled(Boolean calledFromRegenerateVisibleRows)

   at Infragistics.Win.UltraWinGrid.RowScrollRegion.RegenerateVisibleRows(Boolean resetScrollInfo)

   at Infragistics.Win.UltraWinGrid.RowScrollRegion.WillScrollbarBeShown(ScrollbarVisibility assumeColScrollbarsVisible)

   at Infragistics.Win.UltraWinGrid.RowScrollRegion.PositionScrollbar(Boolean resetScrollInfo)

   at Infragistics.Win.UltraWinGrid.ScrollRegionBase.SetOriginAndExtent(Int32 origin, Int32 extent)

   at Infragistics.Win.UltraWinGrid.RowScrollRegion.SetOriginAndExtent(Int32 origin, Int32 extent)

   at Infragistics.Win.UltraWinGrid.DataAreaUIElement.ResizeRowScrollRegions()

   at Infragistics.Win.UltraWinGrid.DataAreaUIElement.PositionChildElements()

   at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)

   at Infragistics.Win.UltraWinGrid.DataAreaUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)

   at Infragistics.Win.UltraWinGrid.DataAreaUIElement.set_Rect(Rectangle value)

   at Infragistics.Win.UltraWinGrid.UltraGridUIElement.PositionChildElements()

   at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)

   at Infragistics.Win.UltraWinGrid.UltraGridUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)

   at Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics)

   at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize, Boolean preventAlphaBlendGraphics)

   at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode)

   at Infragistics.Win.UltraWinGrid.UltraGridUIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode)

   at Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe)

   at Infragistics.Win.UltraWinGrid.UltraGrid.OnPaint(PaintEventArgs pe)

   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)

   at System.Windows.Forms.Control.WmPaint(Message& m)

   at System.Windows.Forms.Control.WndProc(Message& m)

   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

This happens with version 9.2.20092.2017. Before we were running the same application with version 8.3.20083.1009 and never had this issue.

 

Looking at the source code this seems to be happening when adding a new cache item to the internal cache. Comparing this to the 8.3 version we see that all this caching thing is new.

Something catched our eyes, though, in the source code. When looking at the usage of this cache in all other places we can see that it is used 4 times: in ScrollCountInternal, RowSpacingBeforeResolved, RowSpacingAfterResolved and BaseHeight. All but ScrollCountInternal use the following code

// MBS 5/13/09 - TFS17523
//cachedInfo.Add(this, rowInfo);
cachedInfo[this] = rowInfo;


Only the ScrollCountInternal still uses the cachedInfo.Add(this, rowInfo) which finally raises the exception.

May this be a bug you have seen before in the other three properties but missed to fix in the fourth? I'm sure that with cachedInfo[this] = rowInfo in ScrollCountInternal we would never get the above exception and thus red cross in our grid.

Thanks

 

 

Parents Reply Children