Winform databining with Infragistics UltraGrid

Posts   
 
    
Barry
User
Posts: 232
Joined: 17-Aug-2005
# Posted on: 02-May-2006 09:06:42   

I've a winform which have an entity collection and bind it to Infragistics UltraGrid by a BindingSource. After migrating to v2, it threw the following exception when I load the form. I've no ideas about it. rage


Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

   at System.ThrowHelper.ThrowArgumentOutOfRangeException()
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore`1.get_Item(Int32 index)
   at SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.GetEntityAtIndex(Int32 index)
   at SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.System.Collections.IList.get_Item(Int32 index)
   at System.Windows.Forms.BindingSource.get_Item(Int32 index)
   at Infragistics.Win.UltraWinGrid.RowsCollection.SyncRowsHelper(IList boundList)
   at Infragistics.Win.UltraWinGrid.RowsCollection.SyncRows()
   at Infragistics.Win.UltraWinGrid.RowsCollection.EnsureNotDirty()
   at Infragistics.Win.UltraWinGrid.ScrollCountManagerSparseArray.VerifyAgainstScrollVersion()
   at Infragistics.Win.UltraWinGrid.ScrollCountManagerSparseArray.GetItemAtVisibleIndex(Int32 visibleIndex)
   at Infragistics.Win.UltraWinGrid.RowsCollection.GetRowAtVisibleIndex(Int32 visibleIndex, Boolean includeSpecialRows)
   at Infragistics.Win.UltraWinGrid.RowsCollection.GetFirstVisibleRow(Boolean includeSpecialRows)
   at Infragistics.Win.UltraWinGrid.RowsCollection.GetFirstVisibleRow()
   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.RegenerateVisibleRows()
   at Infragistics.Win.UltraWinGrid.RowScrollRegion.WillScrollbarBeShown(ScrollbarVisibility assumeColScrollbarsVisible)
   at Infragistics.Win.UltraWinGrid.ScrollRegionBase.WillScrollbarBeShown()
   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.UltraWinGrid.UltraGridUIElement.set_Rect(Rectangle value)
   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, Boolean disposeEventArgs)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(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)

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39897
Joined: 17-Aug-2003
# Posted on: 02-May-2006 10:32:41   

During design time databinding in vs.net, do you see the same error occur?

Is the collection EMPTY or is there data?

You load the form and it directly crashes, or did you do something with the grid/form? (very important)

With normal .NET 2.0 gridview and janus grids I didn't see a problem.

Frans Bouma | Lead developer LLBLGen Pro
Barry
User
Posts: 232
Joined: 17-Aug-2005
# Posted on: 02-May-2006 12:33:54   

I found what's the problem, EntityCollection.Count does not equal to BindingSource.Count after doind the following code.

BindingSource.Count is larger than EntityCollection.Count, therefore, when I click move next button several times, the index requested by BindingSource larger than last index of EntityCollection.

When I do the same task in v1, the BindingSource.Count is still equal to EntityCollection.Count.


EntityCollection<OrderEntity> orders = customer.Orders
orders[3] = new OrderEntity();

I've prepared a sample program to duplicate the problem, may I send you to have a look?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39897
Joined: 17-Aug-2003
# Posted on: 02-May-2006 12:41:58   

Ok, though I don't have the infragistics ultragrid in a later version than 2004.1.

If you can reproduce it with a gridview control it would be great (I just need the simple steps you're doing, like binding the collection, adding a new instance in code etc.).

It's an event order problem I think, which are usually hard to track down, so a proper working example would be very nice. Thanks.

Frans Bouma | Lead developer LLBLGen Pro
Barry
User
Posts: 232
Joined: 17-Aug-2005
# Posted on: 02-May-2006 12:55:57   

Otis wrote:

Ok, though I don't have the infragistics ultragrid in a later version than 2004.1.

If you can reproduce it with a gridview control it would be great (I just need the simple steps you're doing, like binding the collection, adding a new instance in code etc.).

It's an event order problem I think, which are usually hard to track down, so a proper working example would be very nice. Thanks.

It can reproduce with a standatd gridview control. smile I've just mailed you. Thank you very much!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39897
Joined: 17-Aug-2003
# Posted on: 02-May-2006 13:15:08   

Thanks Barry, I received it. Will look into it. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39897
Joined: 17-Aug-2003
# Posted on: 02-May-2006 16:36:28   

Reproduced. In a gridview I get 1 row too many. When I add a new entity through code, the view adds an extra index, which is causing the problems.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39897
Joined: 17-Aug-2003
# Posted on: 02-May-2006 17:21:14   

Fixed in next build.

Frans Bouma | Lead developer LLBLGen Pro