C# 循环为textbox赋值

2025-03-06 23:24:30
推荐回答(1个)
回答1:

        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; }
            }
        }