6

I have a simple DTO class which I set as the datasource of a bindingsource on a form.

The form contains a custom control with a Value property. This is the property:

[Browsable(false)]
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
public virtual T Value
{
    get { return this.value; }
    set { this.value = value; }
}

When the control is bound to the bindingsource, the setter is called 6 times. When the control is not bound, the setter is called only 2 times

In both cases, the first call is because the designer code has a line:

mycontrol.Value = null;

And the last call is because I set a value. So the first and last calls are normal. However when the control is bound, why is the setter called an extra 4 times?

CSDev
  • 3,177
  • 6
  • 19
  • 37
Ivan-Mark Debono
  • 15,500
  • 29
  • 132
  • 263
  • If a property change on object that is databinded on the binding datasource. the whole bindingsource is being refreshed. Which triggers all these getters and setters. I guess this is the case. – Sievajet Dec 20 '17 at 22:55

0 Answers0