I'm using an EditableRootList and binding it to a DataGridView through a BindingSource.
When I delete the last object in the list using in-place editing, the DataGridView throws an execption stating that 'System.IndexOutOfRangeException: Index 41 does not have a value.'
I'm trying to use the DataError event of the DataGridView control to select the row above the deleted row, but the deleted row stays in the DataGridView with no data in the cells.
How can I get the DataGridView to delete a row in the way that the user expects?
Tray
Hi Rocky,
The ERBL is called CategoryList.
I have a Category root class with a private mCategoryID as Integer as the Id value. This member is returned as an object in the GetIdValue() method. mCategoryID is an identity field (incremental) updated from the db during Save(). I have not implemented a temporary primary key field in the class as the object is being updated everytime the user moves away from the row, so I gathered that there would not be any conflicts (only 1 new item can exists at a time - it either gets cancelled or accepted before any other operations can be performed).
Any ideas?
Love the framework - brilliant job.
Hi again Rocky,
I decided to try using a SortedBindingList to add some functionality for the user and it fixed my deletion problem. (NB: I got the exception message above for any index in the list - not only the last index.)
Not sure why, but the ERLB doesn't seem to handle the in-place deletion of an object as well as the SortedBindingList does. Any ideas Rocky?
This has now created another problem that I have to investigate:
I noticed that SortedBindingList does not have an AddNewCore() method for the databinding to call.
Anyway, I'll keep looking around.
If you could point me in the right direction, that would be great
Tray
To follow on, here's a very simple ERLB bound to a grid - and a SortedBindingList view of that ERLB bound to another grid.
I set up the Root object so its unique id value is assigned by DP_Insert(), so it should be quite comparable to your example. I'm able to add and remove items from the grid without a problem, so I'm wondering if you can look at this and see how it differs from what you are doing?
Copyright (c) Marimer LLC