如何处理输入的文本框事件? [英] How do I handle textbox events for input?

查看:88
本文介绍了如何处理输入的文本框事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个文本框,用户将为其提供值.当它们对所有三个文本框都有有效值时,如何自动计算一个值并将其显示在第四个文本框中?

I have 3 textboxes that a user will supply values for. When they have valid values for all three textboxes, how do I automatically calculate a value and display it in a 4th textbox?

推荐答案

按顺序输入值(TextBox1中的第一个输入,TextBox2中的第二个输入和TextBox3中的第三个输入),您需要挂接所有三个TextBoxChanged事件.

值得庆幸的是,您可以编写一个方法来执行此操作,并将其附加到每个TextBoxChanged事件.然后,只需检查以确保三个框中的每个都有值并进行计算即可.
Well, unless you force the user to enter the values in order (first input in TextBox1, second input in TextBox2 and third input in TextBox3), you need to hook all three TextBoxChanged events.

Thankfully, you can write a single method to do this and just attach it to each TextBoxChanged event. Then, just check to make sure there are values in each of the three boxes and do your calculations.


您可以在第三个文本框的"onchange"事件中编写计算代码
You can write your calculation code in "onchange" event of 3rd textbox


再次做作业,在 4th 1st,2nd&中编写计算代码(编写单个函数).第三个文本框TextChanged事件.在此之后,不要问这样的问题,如果您发现任何问题,请先尝试一下,然后将您尝试过的代码添加到&在这里寻求帮助.
Homework again, write the calculation code(write a single function) in 4th 1st, 2nd & 3rd textboxes TextChanged event. Here after don''t ask such questions try yourself first if you find any issues post your code which you have tried & ask help here.


这篇关于如何处理输入的文本框事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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