Click here to Skip to main content
15,896,348 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I a have a Checkbox on my form witch checked property is bound to a single object's boolean property. The update mode is set to OnPropertychanged cause there's no need for validation and i don't want the user having to click else where or press tab to commit that kind of change.

The problem is that the BindingSource calls the object's property setter a second time right after the checkbox looses focus just as if the update mode was OnValidation! That cause a terrible mess in my application...

The object implements the INotifyPropertyChanged but i removed the call to my helper method that raise the PropertyChanged event to see if that was the cause of that double call and it's not.

I just don't get it! why that behavior?
Posted
Comments
Sergey Alexandrovich Kryukov 8-Nov-13 14:57pm    
It is called twice because you programmed it this way, nothing else. How can we know what have you done? Use the debugger.
—SA

Please see my comment to the question.

Such problems are easily resolved using the debugger with one of its wonderful tools: "Call Stack" window. If you use Visual Studio, use [main menu] Debug => Windows => Call Stack, and a breakpoint at the property setter. The stack will show you where the call comes at first place and other cases.

—SA
 
Share this answer
 
v2
I always make extensive use of all debugging features and logic to track problems like these, the call stack does not help unless i turn "just my code" off and dive into that stuff the debug output shows me. It sometimes help find errors in my own code but not always.

I solved this issue with that stupid kind of workaround i hate; by modifying my property setter in a way to ignore the unwanted call by comparing "value" with the Private Field of the class's property and it work like a expected.

I Just can't imagine working without Data Bindings but i frequently have to face situations like this with the bindingsource component.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900