We recently encountered the same issue reported in the below thread.
http://ko.infragistics.com/community/forums/p/32111/488193.aspx#488193
System.InvalidCastException: Unable to cast object of type 'Infragistics.Win.UltraWinGrid.UltraGridRow' to type 'Infragistics.Win.UltraWinGrid.UltraGridGroupByRow'.
at Infragistics.Win.UltraWinGrid.RowsCollection.SyncRows_Add(UltraGridRow row, Int32 desiredIndex)
at Infragistics.Win.UltraWinGrid.RowsCollection.SyncRowsHelper(IList boundList)
at Infragistics.Win.UltraWinGrid.RowsCollection.SyncRows()
at Infragistics.Win.UltraWinGrid.RowsCollection.VerifyGroupByVersionHelper()
at Infragistics.Win.UltraWinGrid.UltraGridRow.get_ParentRow()
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.RegenerateVisibleRows(Boolean resetScrollInfo)
at Infragistics.Win.UltraWinGrid.RowScrollRegion.WillScrollbarBeShown(ScrollbarVisibility assumeColScrollbarsVisible)
at Infragistics.Win.UltraWinGrid.RowScrollRegionsCollection.AreScrollbarsVisible(ScrollbarVisibility assumeColScrollbarsVisible)
at Infragistics.Win.UltraWinGrid.ColScrollRegion.ResetScrollInfo()
at Infragistics.Win.UltraWinGrid.ColScrollRegion.RegenerateVisibleHeaders()
at Infragistics.Win.UltraWinGrid.ColScrollRegionsCollection.InitializeMetricsHelper()
at Infragistics.Win.UltraWinGrid.ColScrollRegionsCollection.InitializeMetrics()
at Infragistics.Win.UltraWinGrid.RowScrollRegion.PositionScrollbar(Boolean resetScrollInfo)
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.set_Rect(Rectangle value)
at Infragistics.Win.UltraWinGrid.UltraGridUIElement.PositionChildElements()
at Infragistics.Win.UltraWinGrid.UltraGridUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
at Infragistics.Win.UIElement.VerifyChildElements(Boolean recursive)
at Infragistics.Win.UltraWinGrid.UltraGridUIElement.InternalInitializeRect(Boolean verify)
at Infragistics.Win.UltraWinGrid.UltraGridLayout.GetUIElement(Boolean verify, Boolean forceInitializeRect)
at Infragistics.Win.UltraWinGrid.UltraGrid.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam): Unable to cast object of type 'Infragistics.Win.UltraWinGrid.UltraGridRow' to type 'Infragistics.Win.UltraWinGrid.UltraGridGroupByRow'.
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
It is not so easy to reproduce. Sometimes it occurs when the grid view is brought to front. What could be the cause of this error?
Hi Amber,
Thank you for posting in our forums.
Looking in our internal issue tracking system a similar issue resolved in version 9.2 and higher. If you are using an older version, my suggestion to you is to upgrade it and see if the issue is resolved. Note that you can use the 15.1 trial in order to evaluate if your issue is indeed resolved in it.
Please let me know if you have any additional questions.
Hi, I am facing the above issue and I am using "Infragistics4.Win.UltraWinGrid.v14.2.dll", can somebody please help to resolve this issue?
Hi Sumeet,
In order to be able to resolve this issue, please provide us with more information about it. Is the stack trace identical to the one posted above? Under what circumstances does the exception occur? What are the steps to reproduce it? Can you provide us with a small project that reproduces the exception?
I am looking forward to hearing from you.
Hi Dimitar,
Thanks for your reply, please find the below stack trace for your reference:
System.InvalidCastException: Unable to cast object of type 'Infragistics.Win.UltraWinGrid.UltraGridRow' to type 'Infragistics.Win.UltraWinGrid.UltraGridGroupByRow'. at grdCollection_AfterSelectChange(Object sender, AfterSelectChangeEventArgs e) at Infragistics.Win.UltraWinGrid.UltraGrid.OnAfterSelectChange(AfterSelectChangeEventArgs e) at Infragistics.Win.UltraWinGrid.UltraGrid.FireEvent(GridEventIds id, EventArgs e) at Infragistics.Win.UltraWinGrid.UltraGrid.SelectNewSelection(Type type, Selected selected) at Infragistics.Win.UltraWinGrid.UltraGrid.ClearAllSelected(Boolean dontClearPivotItems) at Infragistics.Win.UltraWinGrid.UltraGrid.OnBasePropChanged(PropChangeInfo propChange) at Infragistics.Win.UltraWinGrid.UltraGridBase.OnSubObjectPropChanged(PropChangeInfo propChange) at Infragistics.Shared.SubObjectBase.NotifyPropChange(PropChangeInfo trigger) at Infragistics.Win.UltraWinGrid.UltraGridLayout.ClearViewStyle(Boolean groupByAffected) at Infragistics.Win.UltraWinGrid.UltraGridLayout.set_ViewStyleBand(ViewStyleBand value) at Controller.RenderLayout(Boolean IfResizeComponents) at UIController.BindSectionControlInternal(Int32 width, Boolean load, IContentElement pChildSection) at Controller.BindSectionControlInternal(Int32 width, Boolean load, IContentElement pChildSection) at UIBaseAdapter.BindSectionControl(Int32 width, StateInfo pStateInfo, IContentElement pChildSection) at CompositeSectionAdapter.BindSectionControlInternal(Int32 width, Boolean load, IContentElement pChildSection) at UIBaseAdapter.BindSectionControl(Int32 width, StateInfo pStateInfo, IContentElement pChildSection) at UIMain.BindSectionAndChildSection(IContentElement pSection, IContentElement pChildSection)
and here is the code snippet from grdCollection_AfterSelectChange(Object sender, AfterSelectChangeEventArgs e) event:
For Each row As UltraGridRow In grdCollection.Rows If row.ChildBands IsNot Nothing AndAlso row.ChildBands.Count > 0 Then For Each childRow As UltraGridRow In row.ChildBands(0).Rows If childRow.Cells IsNot Nothing Then If childRow IsNot grdCollection.ActiveRow Then Status = childRow.Cells("Status").Value.ToString type = childRow.Cells("type").Value.ToString If Status = "Enter" Then UpdateStatus() End If If _typeList.Contains(type) Then UpdateStatus() End If End If End If Next Else If row.Cells IsNot Nothing Then If row IsNot grdCollection.ActiveRow Then Status = row.Cells("Status").Value.ToString type = row.Cells("type").Value.ToString If Status = "Enter" Then UpdateStatus() End If If _typeList.Contains(type) Then UpdateStatus() End If End If End If End If Status = type = Nothing Next
I hope this will help you
Thank you for the reply.
This exception is caused by the code in your AfterSelectChange method. The grid seems to be functioning fine and then something in the event throws this exception. Since I can’t run your code I am not sure what exactly is causing the exception. If you are able to create a small sample that reproduces this issue I will be glad to research it and let you know what causes this issue and how to resolve it.