请问你是要实现通过textbox的click时间来动态显示,
程序代码:
int sum = 0;
string str = null;
int i = 0;
private void textBox1_Click(object sender, EventArgs e) //通过textbox的click时间来动态显示
{
i++;
sum += i;
str = "i=" + Convert.ToString(i) + " sum=" + Convert.ToString(sum);
textBox1.Text = str;
}
private void Form3_Load(object sender, EventArgs e)
{
str = "i=" + Convert.ToString(i) + " sum=" + Convert.ToString(sum);
textBox1.Text = str;
}
还要要窗体一运行就自动显示?通过Timer控件的Tick时间来实现
设置timer1.Enabled=true,通过改变其Interval属性值来改变动态显示的频率;
程序代码:
int sum = 0;
string str = null;
int i = 0;
private void Form3_Load(object sender, EventArgs e)
{
str = "i=" + Convert.ToString(i) + " sum=" + Convert.ToString(sum);
textBox1.Text = str;
}
private void timer1_Tick(object sender, EventArgs e)
{
i++;
sum += i;
str = "i=" + Convert.ToString(i) + " sum=" + Convert.ToString(sum);
textBox1.Text = str;
}