求一个很简单的代码,显示一个界面,上面数字从1跳到100,间隔1秒跳1,这样子。。

解决方案 »

  1.   

    for(int i=1;i<=100;i++){
        this.lbl.Text=i;
        Thread.Sleep(1000);
    }
      

  2.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using System.Threading;namespace _
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                for (int i = 1; i <= 100; i++)
                {
                    this.label1.Text = i.ToString();
                    Thread.Sleep(100);
                }
            }
        }
    }我这个怎么全部结束才弹出窗口啊,求解
      

  3.   

    不用按钮就写在Form_Load中,加载窗体时触发。
      

  4.   

    使用Thread.Sleep(1000);不会出现数字跳动。还是放在timer控件中写代码吧
      

  5.   

    看了上面的代码。
      凡是有sleep 的建义不要用!
    我建义用timer ,的tick
      

  6.   

    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 test
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            int time = 0;
            int i = 1;
            private void Change()
            {
                i++;
                label1.Text = i.ToString();
            }        private void timer1_Tick(object sender, EventArgs e)
            {
                 time++;
                 if (time % 10 == 0)
                 {
                     Change();
                 }
                 if (i >= 100)
                 {
                     timer1.Stop();
                 }
            }
        }
    }