程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#基礎知識 >> c#進度條 progressBar 使用方法的小例子

c#進度條 progressBar 使用方法的小例子

編輯:C#基礎知識

代碼如下:

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

namespace HCMDoImport
{
    public partial class ProcessBarForm : BaseForm
    {
        int processPercent = 0;
        string message = "";

        public string Message
        {
            get { return message; }
            set
            {
                message = value;
                this.label1.Text = message;
            }
        }

        public int ProcessPercent
        {
            get { return processPercent; }
            set
            {
                processPercent = value;
                if (processPercent >= 100)
                    this.Close();
                this.progressBar1.Value = processPercent;
            }
        }

        public ProcessBarForm()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 更新進度
        /// </summary>
        /// <param name="percent">進度,小於等於100</param>
        /// <param name="message">消息</param>
        public void ShowProcess(int percent,string message)
        {
            this.Show();
            this.ProcessPercent = percent;
            this.Message = message;
            this.progressBar1.Refresh();
            this.label1.Refresh();
        }

        private void ProcessBarForm_Load(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
        }

        private void ProcessBarForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.Cursor = Cursors.Default;
        }
    }
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved