-
Sep 26th, 2005, 02:22 PM
#1
Thread Starter
New Member
datagrid, arraylist System.IndexOutOfRangeException error
I am using VB.Net to create a datagrid (OrderGrid) and I am binding it to an arraylist(OrderArrayList). The arraylist is composed of objects of a user defined class (OrderClass).
The datagrid is being used to display all the properties of these objects contained in the arraylist.
The datagrid is able to handle Additions, Modifications, and Removals of objects from the arraylist. Any change done is properly displayed on the datagrid in normal situation.
The problem happens when the speed of Additions, Modifications, and particularly Removals on the objects contained in the arraylist increase.
As that happens I get the following error:
System.IndexOutOfRangeException: No value at index 5.
at System.Windows.Forms.CurrencyManager.get_Item(Int32 index)
at System.Windows.Forms.DataGridRow.PaintHeader(Graphics g, Rectangle visualBounds, Boolean alignToRight, Boolean rowIsDirty)
at System.Windows.Forms.DataGridRelationshipRow.PaintHeaderInside(Graphics g, Rectangle bounds, Brush backBr, Boolean alignToRight, Boolean isDirty)
at System.Windows.Forms.DataGridRelationshipRow.PaintHeader(Graphics g, Rectangle bounds, Boolean alignToRight, Boolean isDirty)
at System.Windows.Forms.DataGrid.PaintRows(Graphics g, Rectangle& boundingRect)
at System.Windows.Forms.DataGrid.PaintGrid(Graphics g, Rectangle gridBounds)
at System.Windows.Forms.DataGrid.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.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.UpdateWindow(HandleRef hWnd)
at System.Windows.Forms.Control.Update()
at System.Windows.Forms.Control.Refresh()
at MktDesignPattern.Display.OrderGrid() in C:\Display.vb:line 414
At line 414 I am calling the OrderGrid.Refresh() after I am done with removal of an object in the arraylist.
I would appreciate if anyone can help me in dealing with this error.
I have read few articles on the MSDN about databinding and the behaviour of datagrids, and have extensively searched ab't this problem on userforums and have tried to implement the suggestions provided there to the best of my knowledge. A lot of people seem to have similar problem but this problem is unique because I get it only when the change/add/remove happens on the objects contained in the arraylist happens at a higher speed.
I was using DataSet and DataTables intially and was getting the unhandledexception NullObjectReferenceException, when I switched to ArrayList I started getting System.IndexOutOfRangeException.
I am using synchronized arraylist and I am also making sure that there is no concurrent access of the objects in the arraylist.
I am assuming that this error is happening during the course of datagrid trying to push whatever additions/changes/removals in the arraylist onto the screen. I remove the databinding before I do any changes, make the OrderGrid.datasource = Nothing, refresh the grid make the change to the arraylist and rebind and refresh the data but even that does not seem to take care of this exception.
I would be glad to give any other information if someone can help me.
-Sumit
-
Sep 26th, 2005, 11:25 PM
#2
Junior Member
Re: datagrid, arraylist System.IndexOutOfRangeException error
Why dont you program with command builder?
I think, using code is better than tool because when you upadte through table.upadate
there are alot of errors which are difficult to catch.
-
Dec 1st, 2021, 01:28 PM
#3
New Member
Re: datagrid, arraylist System.IndexOutOfRangeException error
This is quite old, but were you able to solve this? I´m having an identical exception here and no way to figure out from where it is coming.
Thanks
-
Dec 1st, 2021, 01:47 PM
#4
Re: datagrid, arraylist System.IndexOutOfRangeException error
Originally Posted by Leonardo_
This is quite old, but were you able to solve this? I´m having an identical exception here and no way to figure out from where it is coming.
Thanks
Indices are zero to count - 1. Any number outside that range gives an IndexOutOfRangeException
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 1st, 2021, 01:59 PM
#5
Re: datagrid, arraylist System.IndexOutOfRangeException error
Originally Posted by Leonardo_
This is quite old, but were you able to solve this? I´m having an identical exception here and no way to figure out from where it is coming.
Thanks
If .Paul's answer doesn't help you solve your problem then you really should start a new thread and not dig up a thread this old. Post the relevant code, indicate which line is causing the error.
That being said, you should be able put a break point at the line that errors and check the value of any index's. You probably can spot the bad index.
-
Dec 1st, 2021, 03:29 PM
#6
New Member
Re: datagrid, arraylist System.IndexOutOfRangeException error
The reason I didn't create a new thread is because the exception I´m receiving is identical to this old post.
The difference is that the stack trace starts in DebuggableCallback and it is being very difficult to find the point where the flow is starting (to use breakpoints and debug).
System.IndexOutOfRangeException: No value at index 0
at System.Windows.Forms.CurrencyManager.get_Item(Int32 index)
at System.Windows.Forms.DataGridRow.PaintHeader(Graphics g, Rectangle visualBounds, Boolean alignToRight, Boolean rowIsDirty)
at System.Windows.Forms.DataGridRelationshipRow.PaintHeaderInside(Graphics g, Rectangle bounds, Brush backBr, Boolean alignToRight, Boolean isDirty)
at System.Windows.Forms.DataGridRelationshipRow.PaintHeader(Graphics g, Rectangle bounds, Boolean alignToRight, Boolean isDirty)
at System.Windows.Forms.DataGrid.PaintRows(Graphics g, Rectangle& boundingRect)
at System.Windows.Forms.DataGrid.PaintGrid(Graphics g, Rectangle gridBounds)
at System.Windows.Forms.DataGrid.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.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
-
Dec 1st, 2021, 08:00 PM
#7
Re: datagrid, arraylist System.IndexOutOfRangeException error
Originally Posted by Leonardo_
The reason I didn't create a new thread is because the exception I´m receiving is identical to this old post.
The difference is that the stack trace starts in DebuggableCallback and it is being very difficult to find the point where the flow is starting (to use breakpoints and debug).
System.IndexOutOfRangeException: No value at index 0
at System.Windows.Forms.CurrencyManager.get_Item(Int32 index)
at System.Windows.Forms.DataGridRow.PaintHeader(Graphics g, Rectangle visualBounds, Boolean alignToRight, Boolean rowIsDirty)
at System.Windows.Forms.DataGridRelationshipRow.PaintHeaderInside(Graphics g, Rectangle bounds, Brush backBr, Boolean alignToRight, Boolean isDirty)
at System.Windows.Forms.DataGridRelationshipRow.PaintHeader(Graphics g, Rectangle bounds, Boolean alignToRight, Boolean isDirty)
at System.Windows.Forms.DataGrid.PaintRows(Graphics g, Rectangle& boundingRect)
at System.Windows.Forms.DataGrid.PaintGrid(Graphics g, Rectangle gridBounds)
at System.Windows.Forms.DataGrid.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.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Start a new thread and provide all the relevant details, including exactly what the user and/or the application is doing when the exception is thrown.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|