'How to Bind TextBox from Multiple Other Controls
What I Have
I have a form with 3 UserControls that contain source fields to be used to calculate another field in a target UserControl.
UserControl1 (uc1)
- StartDate DatePicker (dpStart)
- EndDate DatePicker (dpEnd)
UserControl2 (uc2)
- Rate TextBox (txtRate)
UserControl3 (uc3)
- Amount TextBox (txtAmount)
UserControl 4 (uc4)
- CalculatedValue TextBox (txtCalc)
Formula to calculate txtCalc is below
txtCalc.Text = (dpEnd.Value - dpStart.Value).TotalDays * txtRate.Text * txtAmount.Text
What I Want To Achieve
Whenever I change a value in any of the first 3 UserControls, the Text in txtCalc should update with calculated value.
What I Have Tried
I have tried DataBindings but it appears to be only for a single field.
e.g.
uc4.txtAmount.DataBindings.Add("Text", uc2.txtRate, "Text", true, DataSourceUpdateMode.Never);
Would really appreciate your inputs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
