Click here to Skip to main content
13,447,595 members (51,240 online)
Rate this:
Please Sign up or sign in to vote.
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 8-Nov-13 8:19am
It is called twice because you programmed it this way, nothing else. How can we know what have you done? Use the debugger.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180318.3 | Last Updated 8 Nov 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100