zoukankan      html  css  js  c++  java
  • WinForm简单进度条

    无标题

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        int current = 0;
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            progressBar1.Maximum = (int)numericUpDown1.Value;
            for (int i = 0; i < progressBar1.Maximum; i++)
            {
                System.Threading.Thread.Sleep(10);
                backgroundWorker1.ReportProgress(++current);
            }
            //MessageBox.Show(current.ToString());   
        }
     
        private void Form1_Load(object sender, EventArgs e)
        {
     
        }
     
        private void button1_Click(object sender, EventArgs e)
        {
            try { int.Parse(numericUpDown1.Text); }
            catch
            {
                MessageBox.Show("工作量必须为数字!");
                return;
            }
            if (backgroundWorker1.IsBusy)
            {
                MessageBox.Show("已经在处理中,请稍后!");
                return;
            }
     
            backgroundWorker1.RunWorkerAsync();
        }
     
        private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            progressBar1.Value = e.ProgressPercentage;
        }
     
        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            progressBar1.Value = 0;
            MessageBox.Show("OK<");
        }
    }
  • 相关阅读:
    七牛云上传文件
    微博三方登录
    异步任务 --- django-celery
    阿里云短信服务
    Redis五大数据结构和使用方法
    千万不要买我们家的鞋子!
    Firebug控制台详解
    【转】android 按home键返回到桌面后,再按桌面应用图标又重新打开该应用的解决方法
    【转】android中webview使用的一些细节
    JSONException: Value of type java.lang.String cannot be converted to JSONObject
  • 原文地址:https://www.cnblogs.com/mmmhhhlll/p/1828354.html
Copyright © 2011-2022 走看看