Bindingsource calling controls' value property multiple times?
Asked Answered
V

0

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?

Veneer answered 11/3, 2016 at 13:57 Comment(1)
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.Peepul

© 2022 - 2024 — McMap. All rights reserved.