![](/img/trans.png)
[英]C# How to display the first, second and third answer only of the combination?
[英]How to multiply two textbox values and display answer to third in c#?
在我的程序中有3个文本框。 这是小计,折扣和总计的总和。小计值将在经过一些计算后显示,我应手动输入折扣。然后在文本框中键入折扣值后,我需要在大计文本框中自动显示总值。如何执行此操作。
txtgrandtotal.Text = (Convert.ToDouble(txtdiscount.Text) * Convert.ToDouble(txtsubtotal.Text)).ToString();
但是它不适用于textchange事件
您可以使用TextBox txtdiscount
控件上的TextChange事件来执行此操作。
添加事件后,您可以按照以下方式进行计算:
private void txtdiscount_TextChanged(object sender, EventArgs e)
{
txtgrandtotal.Text = (Convert.ToDouble(txtdiscount.Text) * Convert.ToDouble(txtsubtotal.Text)).ToString();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.