![](/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.