码迷,mamicode.com
首页 > 其他好文 > 详细

ProgressBarForm 进度条

时间:2019-11-08 13:55:45      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:current   border   form   screen   val   start   mod   nbsp   poi   

ProgressBarForm

    public partial class ProgressBarForm : Form
    {
        private Panel panel1 = new System.Windows.Forms.Panel();
        private ProgressBar progressBar1 = new System.Windows.Forms.ProgressBar();

        public ProgressBarForm()
        {
            InitializeComponent();
            InitializeComponent2();
        }

        public int LoadProgressBarRate(float currentNum, float totalCount)
        {
            float add = 100 / totalCount;
            var currentBar = (int)Math.Ceiling(add * currentNum);
            progressBar1.Value = currentBar >= 0 && currentBar <= 100 ? currentBar : 100;
            Application.DoEvents();
            return currentNum == totalCount ? 1 : 0;
        }

        private void InitializeComponent2()
        {
            this.panel1.SuspendLayout();
            this.SuspendLayout();
            // 
            // panel1
            // 
            this.panel1.Controls.Add(this.progressBar1);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panel1.Location = new System.Drawing.Point(0, 0);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(1000, 50);
            this.panel1.TabIndex = 0;
            // 
            // progressBar1
            // 
            this.progressBar1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.progressBar1.Location = new System.Drawing.Point(0, 0);
            this.progressBar1.Name = "progressBar1";
            this.progressBar1.Size = new System.Drawing.Size(1000, 50);
            this.progressBar1.TabIndex = 0;
            // 
            // ProgressBarForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(1000, 50);
            this.Controls.Add(this.panel1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Name = "ProgressBarForm";
            this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "正在传输";
            this.panel1.ResumeLayout(false);
            this.ResumeLayout(false);
        }
    }

 

ProgressBarForm 进度条

标签:current   border   form   screen   val   start   mod   nbsp   poi   

原文地址:https://www.cnblogs.com/kikyoqiang/p/11819747.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!