在运行时向文本框添加值 c# .NET
Adding values to text boxes at runtime c# .NET
如何在文本框的更改事件中添加文本框的值?
谢谢。
这是为您提供的 telerik 输出
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
public class Form1
{
private int iTotal;
//// add remaining TextBoxes here.
private void myCoolTextBoxes_TextChanged(System.Object sender, System.EventArgs e)
{
iTotal = 0;
//// reset.
//// loop thru all controls on Form.
foreach (Control ctl in this.Controls) {
//// locate TextBoxes that .Name.StartsWith...
if (ctl is TextBox & ctl.Name.StartsWith("TxtPPproduct")) {
if (!string.IsNullOrEmpty(ctl.Text))
iTotal += Convert.ToInt32(ctl.Text);
//// if not a empty value in TextBox, add to Total.
}
}
txtTOTAL.Text = Convert.ToString(iTotal);
//// Display total in your TOTAL TextBox.
}
}
注意:确保将 telerik 设置为 'vb to c#' 而不是 'c# to vb',这样它就不会出错....
如何在文本框的更改事件中添加文本框的值? 谢谢。
这是为您提供的 telerik 输出
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
public class Form1
{
private int iTotal;
//// add remaining TextBoxes here.
private void myCoolTextBoxes_TextChanged(System.Object sender, System.EventArgs e)
{
iTotal = 0;
//// reset.
//// loop thru all controls on Form.
foreach (Control ctl in this.Controls) {
//// locate TextBoxes that .Name.StartsWith...
if (ctl is TextBox & ctl.Name.StartsWith("TxtPPproduct")) {
if (!string.IsNullOrEmpty(ctl.Text))
iTotal += Convert.ToInt32(ctl.Text);
//// if not a empty value in TextBox, add to Total.
}
}
txtTOTAL.Text = Convert.ToString(iTotal);
//// Display total in your TOTAL TextBox.
}
}
注意:确保将 telerik 设置为 'vb to c#' 而不是 'c# to vb',这样它就不会出错....