StatusStrip状态栏控件
1、ToolStripStatusLabel
statusstrip1.Items[1].Text="日期"+DateTime.Now.ToString();
Thread p = new Thread( () => { while (true) { Invoke( (MethodInvoker)(() => { toolStripStatusLabel1.Text = DateTime.Now.ToString("HH时mm分s秒"); } )); Thread.Sleep(1000); } } ); p.IsBackground = true; p.Start();
制作动画窗体
private void Frm_Main_Load(object sender, EventArgs e) { int i=1; Thread P_th = new Thread(//创建线程对象 () =>//使用Lambda表达式 { while (true)//无限循环 { Invoke(//调用窗体线程 (MethodInvoker)(() =>//使用Lambda表达式 { toolStripStatusLabel1.Image = Image.FromFile((++i > 8 ? (i=1) : i).ToString() + ".bmp"); })); Thread.Sleep(50);//线程挂起一秒 } }); P_th.IsBackground = true;//设置线程为后台线程 P_th.Start();//线程开始 }
2、ToolStripProcessBar
this.toolStripProgressBar1.Enabled = true; while (toolStripProgressBar1.Value < toolStripProgressBar1.Maximum) { this.toolStripProgressBar1.PerformStep(); }