Hello,
I have a grid whose datasource is an IBindingList and that is added to a Usercontrol. When showing the control that holds the grid I've gotten the following stack trace intermittently. Note this error does not appear during initialization of the grid, just subsequent attempts to show it among other controls. Any ideas of what might be going on?
************** Exception Text **************System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index at System.Collections.ArrayList.get_Item(Int32 index) at Infragistics.Shared.DisposableObjectCollectionBase.GetItem(Int32 index) at Infragistics.Win.UltraWinGrid.VisibleRowsCollection.get_Item(Int32 index) at Infragistics.Win.UltraWinGrid.ViewStyleBase.OffsetRows(VisibleRowFetchRowContext& context, Int32 index, Int32 count, Int32 amountToOffset) at Infragistics.Win.UltraWinGrid.ViewStyleBase.CreateRowsList_FixedRowsFeature(VisibleRowFetchRowContext& context, VisibleRow parentVisibleRow, UltraGridRow firstSibling) at Infragistics.Win.UltraWinGrid.ViewStyleBase.RecreateRowList(RowScrollRegion rsr) at Infragistics.Win.UltraWinGrid.RowScrollRegion.RegenerateVisibleRows(Boolean resetScrollInfo) at Infragistics.Win.UltraWinGrid.RowScrollRegion.WillScrollbarBeShown(ScrollbarVisibility assumeColScrollbarsVisible) at Infragistics.Win.UltraWinGrid.ViewStyleBase.FitColumnsToWidth() at Infragistics.Win.UltraWinGrid.BandsCollection.CalculateBandMetrics(Int32 pass) at Infragistics.Win.UltraWinGrid.BandsCollection.CalculateBandMetrics() at Infragistics.Win.UltraWinGrid.ColScrollRegionsCollection.InitializeMetricsHelper() at Infragistics.Win.UltraWinGrid.ColScrollRegionsCollection.InitializeMetrics() at Infragistics.Win.UltraWinGrid.UltraGridLayout.ApplyLoadedBands() at Infragistics.Win.UltraWinGrid.UltraGridBase.VerifyDataSourceAttached() at Infragistics.Win.UltraWinGrid.UltraGridBase.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.Show()
Thanks,
sbeaudry
Is your application using threading at all? This kind of error commonly occurs if your applicaiton is using multiple threads without properly marshalling across to the UI Thread.
Yes threading is involved. There are multiple threads used during my application's runtime. The grid is representing the contents of a multi-user database and these mismatches might be happening because another user is changing the data the grid is presenting. Can you provide a high level description of how threads and marshalling are best handled when using the grid?
Well, regardless of whether you are using WinGrid or any Infragistics controls, you have to be very careful about using threads. You need to make sure that no process crosses from one thread to another without marshalling. It's really more complex than I can describe here and I'm sure Microsoft has plenty of documentation on the subject of safely using threads. But some things to check out would be methods like InvokeRequired, BeginInvoke, and Invoke (on Control).
Also, it's important to be aware that if your grid is bound to a data source and you perform any operations on that data source on a different thread than the grid is on, then this will almost certainly cause a problem because the data source will fire events that the grid listens to and it will be responding to these events on the wrong thread. So you must avoid this situation.
Dear Mike,
I have just met the same problem, and after remove the thread in which i was doing some computation with the data in grid, still, the same exception happend.
Do you know which hot fix and where the hot fix is for these exception ? thank you very much : )
You can get the latest hot fixes here:
My Infragistics Keys and Downloads - Download Anything and Everything You Own