Stange error with the dataGridView

Stange error with the dataGridView

Old forum URL: forums.lhotka.net/forums/t/705.aspx


JoOfMetL posted on Monday, July 24, 2006


Process :

Screen ProjectEdit :

Description =  "1"
Role = "Project Manager"

<< Modify Description
<< Change the role of one Ressource
<< Modify Description

Description =  "2"
Role = "Developer"

Click on the button Cancel

Result :

Description =  "1"
Role = "Developer"

So there is a problem.

I think that the problem is the DataGridView call the method EndInit, so a snaphsot is taken.
When the state object is restored :
     - parent one snaphsot (Initial)
     - kind 2 snapshots (Initial + EndInit)
So the object is not entierely restored to this initial state.

Do you have an idea ?

Thank you.


RockfordLhotka replied on Monday, July 24, 2006

I'm not entirely sure what you are saying (the post is a bit cryptic Smile [:)]).

But I think the answer is that you should ONLY use BeginEdit/CancelEdit/EndEdit on the bindingsource objects, never on the business object itself, when doing data binding in Windows Forms 2.0. This has been discussed on a couple threads now, and consistent use of bindingsource methods seems to resolve the issues.

JoOfMetL replied on Monday, July 24, 2006


Thank you for you answer

But, It's just a problem that I have found when I tested the Tracker Project. I don't modify the code or the Framework.

And I tried to explain the process to reproduce the problem.



RockfordLhotka replied on Monday, July 24, 2006

It is true, the current ProjectTracker code does call the n-level undo methods on the object directly and so it doesn't work correctly. I expect to update it for version 2.1, but I have also been waiting for people to more completely establish that the hypothesis about only interacting with bindingsource methods does resolve the issue.

Remember, I move at half-speed, because any change I make has to be made to both the VB and C# code bases, so I hold off making any changes as much as possible - especially if I don't know for sure that they are correct - because that double effort is a serious penalty...

JoOfMetL replied on Monday, July 24, 2006

Ok

I am happy to see there is a solution.

I will try : "only interacting with bindingsource methods", and I will wait the version 2.1

Thank you.


JoOfMetL replied on Tuesday, July 25, 2006

I try to call the method CancelEdit() on the BindingSource but it's doesen't work.

When I change a value of a drop-down list in the datagridview, I think that it calls the EndEdit method, so there is a problem.

I try to put the property CausesValidation to False, and it's works. However, I don't know if it is a good idea.


RockfordLhotka replied on Tuesday, July 25, 2006

In the PTracker forms there are TWO bindingsource controls. You need to tell both to EndEdit or CancelEdit, since both are actively bound to controls. I think you should call EndEdit/CancelEdit on the child bindingsource first, then the parent.

JoOfMetL replied on Tuesday, July 25, 2006

I called the method CancelEdit for the Two Bindingsource but first the parent and after the child.

I try first Child and after Parent, and IT'S WORKING

Thank you

Copyright (c) Marimer LLC