views:

581

answers:

1

Good evening

I've got a little problem with my DataGridView in a .NET Windows Forms project. The grid is read-only and bound to a sortable BindingList<T> which contains custom business objects. My business object class does implement IEditableObject.

Now the BeginEdit and EndEdit methods are called all the time while navigating in the grid. Is there a way to prevent the grid or binding source from doing this? It is explicitly set to read only (ReadOnly = true), so there's no reason at all (no, let's carefully say that I see none) to call these methods over and over.

Thank you for reading :)

Matthias

+1  A: 

After replicating your problem it seems the DataGridView calls a chain of methods/events that end up with calling your IEditableObject event no matter what ...

This happens when you set your BindingList to the DataGridView.DataSource, and when you navigate through the Grid.

Regardless of the EditMode I select for the DataGridView, the code will step into the IEditableObject.EndEdit() method of the BusinessObjects.

It seems this is an old BUG of the framework...I found this Bug Report.

This bug report is very old. I'm not 100% sure if this is still an issue ... maybe there is already some property to solve this.

Any thoughts?

bruno conde
I cannot open the link to the bug report. But great answer though! Thanks a lot. I hope there is some more information about this out there... :)
Mudu
That's strange ... The link seems to be working to me.
bruno conde
Now it works. Seems like it's by design, grmpf.
Mudu