进度条由进度条+label组成,
进度条自行滚动,当到达100%时重新从0%开始,当程序运行完成后进度条隐藏
同时在LABEL中实时显示程序进度,如"正在执行脚本1...","正在执行脚本1..."全部完成后在LABEL上显示"所有脚本执行完成".
请问这样的进度条如何实现,请大神指教,最好有代码给参考.

解决方案 »

  1.   

    这种自定义控件JAVA写过,说简单也简单。就是两个矩形一个固定长宽在底部,用一个同样大小同样位置带指定颜色的矩形盖在上面。百分比之类的变化就是在给带颜色的矩形宽加值。
      

  2.   

    你这种毫无任何有用信息的进度条,直接用个gif实现好了,没必要编程
      

  3.   

    http://www.codeproject.com/Articles/33971/ProgressBar-with-Percentage
      

  4.   

    进度条放图片没问题,怎么按照进度给label赋值呢?不用自定义控件那么复杂吧…没搞过多线程…最好给个代码学习下…
      

  5.   

    我可能没太说清楚,不是要做自定义控件,是用label和ProcessBar两件控件,我把代码放上,ProcessBar我用gif图片实现,Label怎么样根据程度执行状态更新文字(没有循环);
    麻烦帮忙看一下.
    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 ThreadExample
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            //声明一个线程
            private Thread timerThread;        public void AddData()
            {
                //显示lable的值
                this.label1.Text = "正在执行脚本1...";
                //执行脚本1代码
                //......
                //
                Thread.Sleep(500);
                //执行脚本2代码
                //......
                //
                this.label1.Text = "正在执行脚本2...";
                //执行脚本3代码
                //......
                //
                Thread.Sleep(500);
                this.label1.Text = "正在执行脚本3...";
            }
            //更新线程
            public void UpdataThread()
            {
                try
                {
                    //在对控件的调用方法进行调用时,或需要一个简单委托又不想自己定义时可以使用该委托。
                    MethodInvoker mi = new MethodInvoker(this.AddData);
                        //在创建控件的基础句柄所在线程上异步执行指定的委托
                        this.BeginInvoke(mi);
                        Thread.Sleep(50);
                }
                catch (ThreadInterruptedException)
                {
                    //针对具体问题定制异常抛出显示
                }
                finally
                {
                    //做一些处理
                }
            }        //启动线程
            public void StartThread()
            {
                StopThread();
                timerThread = new Thread(new ThreadStart(UpdataThread));
                //获取或设置一个值,该值指示某个线程是否为后台线程。
                timerThread.IsBackground = true;
                timerThread.Start();
            }        //停止线程
            public void StopThread()
            {
                if (timerThread != null)
                {
                    //中断线程
                    timerThread.Interrupt();
                    timerThread = null;
                }
            }        //启动线程,显示结果
            private void button1_Click(object sender, EventArgs e)
            {
                ShowProgressStatus();
            }        //停止线程
            private void button2_Click(object sender, EventArgs e)
            {
                StopProgressStatus();
            }
            private void ShowProgressStatus()
            {
                //调用线程启动函数
                this.label1.Visible = true;
                this.pictureBox1.Visible = true;
                this.StartThread();
            }        private void StopProgressStatus()
            {
                //调用线程停止函数
                this.pictureBox1.Visible = false;
                this.label1.Visible = false;
                this.StopThread();
            }
        }
    }
      

  6.   

    不需要搞多线程,使用backgroundworker可以满足需求
      

  7.   

    不需要搞多线程,使用backgroundworker可以满足需求有例子吗?
      

  8.   

    http://www.cnblogs.com/youring2/archive/2008/11/27/1342041.html
    可以参考这个。