制作带动画效果的状态栏

Posted on 2018-12-26 16:20  努力成长静待花开  阅读(220)  评论(0编辑  收藏  举报

实现效果:

  

知识运用:

  ToolStripStatusLabel控件的Image属性

  public virtual Image Image { get;set; }

 实现代码:

        private void Form1_Load(object sender, EventArgs e)
        {
            int i = 1;  
            string str="";
            Thread th = new Thread(
                () =>
                {
                   while(true)
                   {
                       Invoke((MethodInvoker)(() => 
                       {
                           toolStripStatusLabel1.Image = 
                               Image.FromFile((++i>9?(i=1):i).ToString()+".bmp");
                       }));
                       Thread.Sleep(100);
                   }
                });
            th.IsBackground = true;
            th.Start();
        }