Hello All,
I'm really falling in love with the whole .Net databinding scheme... but apparently there are still a couple of gotchas out there. Let's say that my class has a member variable of type double named Susan
. Well there seems to be no immediate way to bind Susan
to a text box SusanText
because the binding looks something like this
SusanText.DataBindings.Add("Text",datasource,"Property")
And Susan
isn't a property. So I can make Susan
a public property, but that kinda stinks... what if I want to keep Susan
hidden? (I guess I could make Susan
a public property of a private instance of some internal class... but that's a lot of work for a little double.) However, I have a bigger problem coming up, so for the sake of argument let's go ahead and do this:
private double Susan_;
public double Susan{ get; set;}
...
SusanText.DataBindings.Add("Text",this,"Susan")
Then everything initially seems to work as expected. If I alter SusanText
, Susan
is altered correspondingly. However, the problem arrises when I alter Susan
directly. I would like for SusanText
to be automatically updated. So I suspect that I need to make Susan
a subclass of double that implements some sort of IBindable interface, so that if Susan
is databound to SusanText
that the appropriate Events are registered and Susan
will notify others if she is modified.
What is the simplest way to make Susan
do what I want her to do?
Thanks!