文本框中的求和变化 [英] Sumation in textbox change

查看:150
本文介绍了文本框中的求和变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的表单中有几个文本框(10或11),一个文本框总计,

我想要这个结果

我的总文本框中的默认值为0,但是当我在另一个文本框中输入值时,它会更改总文本框中的值.

因此,我该怎么做.

Hi all,

I have several textboxes (10 or 11) in my form, and one textbox for total,

i want result for this

in my total textbox default value is 0 but when i input values in another textboxes it changes value in my total textbox.

so how can i do this.

推荐答案

为每个文本框在下面提到的代码上写一个TextChanged事件处理程序
for each text box write a TextChanged Event handler on that write below mentioned code
private void tbx1_TextChanged(object sender, EventArgs e)
{
   try
   {
      tbx_TotalSum.Text=tbx1.Text+ .....+tbxn.Text;
   }
   catch
   {
      throw;
   }
}


TextChanged [
Update the total textbox value (that is perform the sum) in the TextChanged[^] event handler of any of the other textboxes (you may associate the same event handler to all such textboxes).


在每个文本框的离开事件中,除了总共一个文本框写这个

十进制总和
sum = convert.todecimal(textbox1.text)+ convert.todecimal(textbox2.text)+ convert.todecimal(textbox3.text)
txttotal.text = sum
at leave event of every text box except the total one write this

decimal sum
sum = convert.todecimal(textbox1.text) + convert.todecimal(textbox2.text) +convert.todecimal(textbox3.text)
txttotal.text = sum


这篇关于文本框中的求和变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆