欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

c#进度条 progressBar 使用方法的小例子

程序员文章站 2023-12-12 16:18:59
复制代码 代码如下:using system;using system.collections.generic;using system.componentmodel;us...

复制代码 代码如下:

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;
        }
    }
}

上一篇:

下一篇: