how to do addition of textbox values(Integers) on Lost Focus Property and Show it in TextBlock

三世轮回 提交于 2019-12-12 02:46:55

问题


I have many Textboxes and I want to Add the Values(Sum of Integers) of Textboxes and Show it in a textblock on Lost Focus Property.... For example:

I fill a Textbox with integer 5, the value of Textblock Changes to 5.... And after that I fill another Textbox with 4... Textblock changes to 9.

I short How can I bind single TextBlock to Multiple Textboxes with Lost_Focus Property?

Please Answer I cannot find it anywhere on Web.


回答1:


My Dear, In this way you can easily add textboxes in textblock keep

  int sum=0;
  private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
  {
     sum = sum + Convert.ToInt32(_1.Text);
     Add.Text = sum.ToString();
  }
  private void TextBox_TextChanged_1(object sender, TextChangedEventArgs e)
  {
      sum = sum + Convert.ToInt32(_2.Text);
      Add.Text = sum.ToString();
  }


来源:https://stackoverflow.com/questions/28884542/how-to-do-addition-of-textbox-valuesintegers-on-lost-focus-property-and-show-i

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!