悟生慧

 

使用timer控件控制进度条

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ECS.Simulate
{
    public partial class FrmProgress : Form
    {
        public FrmProgress()
        {
            InitializeComponent();
            this.CenterToParent();
            progressBar1.Maximum = 1000;
            progressBar1.Step = 10;
            timer1.Enabled = true;
        }

        private void FrmProgress_Load(object sender, EventArgs e)
        {

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (this.progressBar1.Value == this.progressBar1.Maximum)
            {
                this.progressBar1.Value = this.progressBar1.Minimum;
            }
            else
            {
                if (StatusData.flag)
                {
                    this.progressBar1.PerformStep();
                    this.Close();
                    this.Dispose();
                    GC.Collect();
                    StatusData.flag = false;
                }
                this.progressBar1.PerformStep();
            }
        }
    }

    public class StatusData
    {
        public static bool flag = false;
    }

}

posted on 2013-08-02 10:33  悟生慧  阅读(854)  评论(0编辑  收藏  举报

导航