zoukankan      html  css  js  c++  java
  • ProgressBar 基础应用(简单)

    创建一个简单的窗体,界面如下:

    image

    “基础应用”按钮对应的代码:


    /// 方法一: /// 修改 progressBar1.Value 来使进度条显示发生变化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEasy_Click(object sender, EventArgs e) { progressBar1.Minimum = 1; progressBar1.Maximum = 100000; for (int i = 0; i < progressBar1.Maximum; i++) { progressBar1.Value = i; } } /// <summary> /// 方法二: /// 设置 Step 属性,调用 PerformStep() 来使进度条显示发生变化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEasy_Click1(object sender, EventArgs e) { progressBar1.Minimum = 1; progressBar1.Maximum = 100000; progressBar1.Step = 1; for (int i = 0; i < progressBar1.Maximum; i++) { progressBar1.PerformStep(); } }

    各分钟按钮对应代码:


    /// <summary> /// 分钟按钮的 Tag 值里分别保存了 2, 5, 10 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAnySecond_Click(object sender, EventArgs e) { progressBar1.Minimum = 0; progressBar1.Maximum = 100; progressBar1.Value = 0; progressBar1.Step = 1; Button btn = sender as Button; timer1.Interval = Convert.ToInt32(btn.Tag) * 10; count = 0; timer1.Enabled = true; } private int count = 0; private void timer1_Tick(object sender, EventArgs e) { progressBar1.PerformStep(); if (++count == 100) { timer1.Enabled = false; } } private void btnStop_Click(object sender, EventArgs e) { progressBar1.Value = 0; timer1.Enabled = false; }
  • 相关阅读:
    MAVEN flex
    计算几何--判断点是否在矩形里
    Maven copy方式列举
    配置 IntelliJ IDEA VM options
    解决访问StackOverFlow太慢的问题
    Android sdk manager 更新 5.0 太难了,终于解决
    为OS X增加环境变量
    激活老电脑的第二春:内存盘为Chrome浏览器做缓存
    Android启动外部应用的方法
    在Activities之间导航
  • 原文地址:https://www.cnblogs.com/SkySoot/p/2267654.html
Copyright © 2011-2022 走看看