Hi I am facing this exception when I am going to assign data source to grid.
Please tell.
I am using ultradatasource and here is the code.
foreach (ColumnInfo colinfo in ColumnCollections) { this.ultraDataSource.Band.Columns.Add(colinfo.GetColumnKey(), Type.GetType("System.String")); }
this.ultraDataSource.Rows.SetCount(GetRowCount()); this.resultsGrid.DisplayLayout.LoadStyle = LoadStyle.LoadOnDemand; this.resultsGrid.DataSource = this.ultraDataSource; at this line below exceptionoccurs.
This happens when I am laoding file above 1000000
This is exception text.
{System.IndexOutOfRangeException: Index was outside the bounds of the array. at Infragistics.Shared.SparseArray.InsertRange(Int32 index, ICollection items) at Infragistics.Shared.SparseArray.AddRange(ICollection items) at Infragistics.Win.UltraWinGrid.RowsCollection.InitNonGroupByRows(IList fireInitializeRowOnTheseRows) at Infragistics.Win.UltraWinGrid.RowsCollection.SyncRowsHelper(IList boundList) at Infragistics.Win.UltraWinGrid.RowsCollection.SyncRows() at Infragistics.Win.UltraWinGrid.RowsCollection.EnsureNotDirty() at Infragistics.Win.UltraWinGrid.RowsCollection.get_Count() at Infragistics.Win.UltraWinGrid.UltraGridBand.GetRowSelectorNumberWidth() at Infragistics.Win.UltraWinGrid.UltraGridLayout.GetRowSelectorWidthDefault(UltraGridBand band) at Infragistics.Win.UltraWinGrid.UltraGridBand.get_RowSelectorWidthResolved() at Infragistics.Win.UltraWinGrid.UltraGridBand.get_RowSelectorExtent() at Infragistics.Win.UltraWinGrid.ColumnHeader.get_RowSelectorExtent() at Infragistics.Win.UltraWinGrid.ColumnHeader.get_Extent() at Infragistics.Win.UltraWinGrid.UltraGridBand.CalculateBandMetrics(UltraGridBand priorBand) 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.UltraGridLayout.ListManagerUpdated(BindingManagerBase bindingManager) at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated() at Infragistics.Win.UltraWinGrid.UltraGridBase.Set_ListManager(Object newDataSource, String newDataMember) at Infragistics.Win.UltraWinGrid.UltraGridBase.set_DataSource(Object value) at Thomson.Financial.Framework.Data.MarketQA.QalResultView.ResetGridBinding()
Hi Syed,
There's not much here to go on.
What version of the grid are you using? Do you have the latest Hot Fix? I remember some problems with the SparseArray that were fixed a long time ago, so maybe you are using an old version.
Another reason for an error like this is if your application is using multiple threads and you are trying to bind across the threads.
(Version 9.2.20092.2035)
I am getting a similar intermittent error. I have a worker thread on the form but it only loads a list of data that is marshaled back to the main thread. The worker thread exits immediately after returning the data. I have run the code by a couple other people who can find no problem with it and I also tried setting a breakpoint in the code where I am adding the rows to the ultradatasource and verified that it is running in the main thread.
My code is very simple:
foreach (var x in r.Results){ultraDataSource1.Rows.Add(x.ToArray());}
2/8/2010 7:26:29 AM System.IndexOutOfRangeException: Index was outside the bounds of the array. at Infragistics.Shared.SparseArray.InsertRange(Int32 index, ICollection items) at Infragistics.Shared.SparseArray.AddRange(ICollection items) at Infragistics.Win.UltraWinGrid.RowsCollection.InitNonGroupByRows(IList fireInitializeRowOnTheseRows) 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() 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.VerifyChildElements(Boolean recursive) at Infragistics.Win.ControlUIElementBase.VerifyIfElementsChanged(Boolean verify, Boolean syncMouseEntered) at Infragistics.Win.ControlUIElementBase.get_CurrentCursor() at Infragistics.Win.UltraControlBase.get_Cursor() at System.Windows.Forms.Control.WmSetCursor(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)
Mike, thanks for the read. I'm not sure I'm in the same situation as the only thing my worker thread does is create a new List<> and send it back to the main thread via System.Threading.SynchronizationContext.Post. There are no dealings with the UI thread or any data connected to the datasource or UI until after the worker thread has ended and it's back in the main thread. Hmm.. .Post() is an async call maybe the worker thread is exiting before all the data gets sent back to the main thread... I'll try changing it to a synchronus .Send()..
Greg
You might want to take a look at this thread:
Work with a dataset bound to a grid on a separate thread - Infragistics Community
It's a discussion of some of the possible pitfalls and dangers of using multiple threads with bound controls.