Add dynamically added textbox value from User Control to main form


In my main form I have a textbox namely textBoxTotalTotal and I want all the dynamically added textbox to be the added/sum in my textBoxTotalTotal How can I achieve that?
In my main form I have this: textBoxTotalTotal
Then in my User Control I have this

 public void textBoxTranspo_TextChanged(object sender, EventArgs e)
   {
  int intTranspo = 0, intBoxDaily = 0;
   if (int.TryParse(textBoxTranspo.Text, out intTranspo) && int.TryParse(textBoxDaily.Text, out intBoxDaily))
   textBoxTotalAmount.Text = (intTranspo + intBoxDaily).ToString();
    }

and

public void textBoxDaily_TextChanged(object sender, EventArgs e)
       {
      int intTranspo = 0, intBoxDaily = 0;
       if (int.TryParse(textBoxTranspo.Text, out intTranspo) && int.TryParse(textBoxDaily.Text, out intBoxDaily))
       textBoxTotalAmount.Text = (intTranspo + intBoxDaily).ToString();
        }

Note that I am dynamically adding that User Control via button in the main form as many times I like. So the textBoxTotalTotal should just add them up wheter a new 2 textbox comes up.



Assuming that UserControls' Parent is Form1 and User Control type MyUserControl: (You should set the correct parent, and user control type)

MyUserControl[] controls = Form1.Controls.OfType<MyUserControl>().ToArray();
int Total = 0;
for(int i=0;i<controls.Length;i++){
    controls[i].Controls.OfType<TextBox>().ToList()
    .ForEach(txt => Total += int.Parse(txt.Text));
}

If you are doing it from the UserControl itself then:

MyUserControl[] controls = Parent.Controls.OfType<MyUserControl>().ToArray();
int Total = 0;
for(int i=0;i<controls.Length;i++){
    controls[i].Controls.OfType<TextBox>().ToList()
    .ForEach(txt => Total += int.Parse(txt.Text));
}