Hi,
I have a data entry form with 2 read-write textboxes and 1 read-only textbox. I want to be able to update the content of the read-only textbox as the user enters number values in the two read-write textboxes.
Obviously in a simple application this is easy using the TextChange event. However, what I would like to do is to use DataBinding. I bind the 3 textboxes to a custom class that have the 3 string properties and make the calculation inside of this class as opposed to inside of the form.
It works well but it is not perfect. Simply because my 3rd texbox value is only updated when the user leaves one of the 2 read-write textboxes. This is not the behaviour I want. I want it to be updated each time the user change the value (every digit entered/removed/changed).
Is there a way to still use DataBinding and do that. I know that DataBinding uses the Leave/Validated events but not the Change event.
Thanks for your help,
Hugo

Textbox databinding in a data Form (Autocalculated fields )
SebastianR
Thanks for your help but I already tried that and it doesn't work. However, I don't understand why.
I am sure there is a solution for this because if there isn't, then I don't see the use of DataBindings. If you have to leave the control to have its DataSource updated what use is it in a window form. The only use I see is for web forms!
Please someone tell me something exists!
Cheers,
Hugo
leonello
textBox1.DataBindings.Add("Text", myDataSource, "Text");
textBox2.DataBindings.Add("Text", textBox1, "Text");
Now if you type in one textbox the other will be updated immediately. If you leave one of the textboxes then the text will be synchronized with your datasource.
In general if you want that one property of your datasource controls multiple properties on multiple controls then make one databinding between your datasource property and a control property and for the other controls make databindings between that control property and the other control properties.
Bonner
1) you aren't doing anything with validation yourself
2) the property of your class that has the concatenated field is readonly (if it's read-write, the control value may get written back on top of the new property value).
On the other hand, I'm not sure this helps you at all: you'd still have to hook all the TextChanged events, and if that's what you're trying to avoid, I don't believe there's a way around it.
Example:
textBox1.TextChanged += new EventHandler(tc);
textBox2.TextChanged += new EventHandler(tc);
void tc(object o, EventArgs e)
{
Validate();
}
(If you're using VB, use AddHandler instead of += .)
-Scott