在运行时c#.NET中向文本框添加值

时间:2015-03-06 09:28:04

标签: mp4

如何在文本框的更改事件中添加文本框的值? 感谢。

1 个答案:

答案 0 :(得分:1)

这是你的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#到vb'所以它没有给出错误....