public partial class Form1 : Form
    {
        public delegate void ShowLable(string count,Label lab);
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Thread thread = new Thread(new ThreadStart(Test));
            thread.Start();
        }
        public void Test()
        {
            for (int i = 0; i < 100; i++)
            {
                ShowLables(i.ToString(), label1);
                System.Threading.Thread.Sleep(100);
            }
        }
        public void ShowLables(string  count,Label lab)
        {
            if (lab.InvokeRequired)
            {
                ShowLable ss = new ShowLable(ShowLables);
                this.Invoke(ss, new object[] { count, lab });
            }
            else
            {
                lab.Text = count.ToString();
            }
        }
    }
- 本文标题: Winform实时更新Label变化的动态值
- 文章分类:【WinForm/WPF】
- 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.
- 上一篇:Winform 设置应用程序图标方法(图解)
- 下一篇: JS点击图片即时刷新验证码图片代码