C# 循环为textbox赋值

int num = 1;

while(true)
{

textbox.text += num;
num++;
if(num >5){break;}

}
这个只能在循环完成后在输入框中显示数字, 有没有什么方法在循环的过程中把数字现在在textbox中?

        private void button1_Click(object sender, EventArgs e)
        {
            int num = 1;

            while (true)
            {
                this.textBox1.Text = num.ToString();
                //刷新界面
                this.textBox1.Update();
                //暂停线程一定时间让眼睛看清楚
                System.Threading.Thread.Sleep(200);
                num++;
                if (num > 5) { break; }
            }
        }

温馨提示:答案为网友推荐,仅供参考