I have started a new Windows form project, and added to the Form1
constructor the following:

Form2 form2 = new Form2();
form2.Show();

Form2 is just a new form with a checkbox added to it.

in the Form2 constructor I've added:

this.checkBox1.DataBindings.Add("Checked", this, "TopMost");

So, I was expecting that the Form2 wasn't hidden by Form1 when the
checkbox was checked, because i have bound Checkbox1.Checked property
to Form2.TopMost property. However, this doesn't work? Why???

I'm completely lost :(

If I change the databinding to:

this.DataBindings.Add("TopMost", this.checkBox1, "Checked");

it works as expected, but i can't understand why. isn't databinding
supossed to be conmutative?

Please help me!

Thanks,
Pedro.

Re: Data Binding Bug by Morten

Morten
Wed Apr 21 08:37:54 CDT 2004

Hi Pedro,

No, DataBinding works one way. To get it both ways you would have to ad=
d =

both DataBindings.

<TargetOwner>.DataBindings(<TargetMember>, <SourceOwner>, <SourceMember>=
);

Happy coding!
Morten Wennevik [C# MVP]

Re: Data Binding Bug by pedrobernabeu

pedrobernabeu
Wed Apr 21 16:10:14 CDT 2004

Hi Morten,

> No, DataBinding works one way. To get it both ways you would have to ad
> d
>
> both DataBindings.
>
> <TargetOwner>.DataBindings(<TargetMember>, <SourceOwner>, <SourceMember>
> );

You can't imagine how those some simple words have changed my
databinding concept in my brain!

Thank you very very much!!!

Pedro.

Re: Data Binding Bug by Morten

Morten
Thu Apr 22 01:05:51 CDT 2004

Glad to be of assistance :)

Happy coding!
Morten Wennevik [C# MVP]

Re: Data Binding Bug by pedrobernabeu

pedrobernabeu
Thu Apr 22 14:36:28 CDT 2004

Morten Wennevik wrote:
> Glad to be of assistance :)

i'm sorry man, but after playing more with the subject, you are wrong.

Databinding works two way. If the datasource throws "changed events"
the bindingmanager updates the targets as soon as a datasourcce
property changes.
if the target control changes, the datasource isn't updated until the
another control gets the focus.

Now everything makes sense!
Thanks anyway,
Pedro

No, DataBinding works one way. To get it both ways you would have to
ad
> d
>
> both DataBindings.
>
> <TargetOwner>.DataBindings(<TargetMember>, <SourceOwner>, <SourceMember>