DataBindings

  • Thread starter Thread starter Chuck Bowling
  • Start date Start date
C

Chuck Bowling

i have a form with a couple of textboxes bound to a collectionbase object.
The code looks like this:

txtName.DataBindings.Add(new Binding("Text", instrumentSet, "Name"));

txtComment.DataBindings.Add(new Binding("Text", instrumentSet, "Comment"));



Maybe I'm looking at things the wrong way but intuitively I'd think that the
binding goes both ways. That is, when I change the text in the textbox it
should automatically change the contents of the object it's bound too. I
know it'd be easy to update the source with an OnChanged event but somehow I
get the feeling that I might be doing something wrong. Can somebody clue me
in here?
 
Chuck,

It should. Does the object that is exposed by the collection base have
a writable Name and Comment property? If they are read-only, then nothing
is updated.

Can you show the collection class as well?

Hope this helps.
 
Whoops... stupid me... no set property... ty...

Nicholas Paldino said:
Chuck,

It should. Does the object that is exposed by the collection base have
a writable Name and Comment property? If they are read-only, then nothing
is updated.

Can you show the collection class as well?

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Chuck Bowling said:
i have a form with a couple of textboxes bound to a collectionbase object.
The code looks like this:

txtName.DataBindings.Add(new Binding("Text", instrumentSet, "Name"));

txtComment.DataBindings.Add(new Binding("Text", instrumentSet,
"Comment"));



Maybe I'm looking at things the wrong way but intuitively I'd think that
the binding goes both ways. That is, when I change the text in the
textbox it should automatically change the contents of the object it's
bound too. I know it'd be easy to update the source with an OnChanged
event but somehow I get the feeling that I might be doing something
wrong. Can somebody clue me in here?
 
Back
Top