想在一个窗体中点击按钮后文本框间隔显示1-10程序如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }        private void button1_Click(object sender, EventArgs e)
        {
            for (int i = 1; i <= 10; i++)
            {
                textBox1.Text = i.ToString();
                Thread.Sleep(100);
            }
        }
    }
}问题:
等待时间后文本框只显示了10,1-9都没有显示,不知何故,请解答下,多谢

解决方案 »

  1.   

    private void button1_Click(object sender, EventArgs e) 
            { 
                StringBuilder sb = new StringBuilder(30);
                for (int i = 1; i <= 10; i++) 
                { 
                    sb.Append(i.ToString());
                    sb.Append(",");
                    Thread.Sleep(100); 
                } 
                textBox1.Text = sb.ToString();
            } 
      

  2.   

    textBox1.Text = i.ToString(); 
    改成
    textBox1.Text+= i.ToString(); 
      

  3.   

    哦我理解错误了,你这个不是这个样子的,应该在这之中加点儿东西        private void button1_Click(object sender, EventArgs e) 
            { 
                for (int i = 1; i <= 10; i++) 
                { 
                    textBox1.Text = i.ToString(); 
                    Application.DoEvents();//加这句话
                    Thread.Sleep(100); 
                } 
            } 
      

  4.   

    textBox1.Text="";
    for (int i = 1; i <= 10; i++)
          textBox1.Text += i.ToString(); 
    少了+号,在字符串操作中,+号表示连接
      

  5.   

    可能我没有说清楚
    是这样的
    textbox显示1,延时后显示2,延时后显示3,。。显示10INTTNY是对的,加上Application.DoEvents();后就可以了
    能不能说说,Application.DoEvents()的意思啊,不明白
      

  6.   

    textBox1.Text += i.ToString()+" ";