• 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; }
  • 相关阅读:
    Struts2取值
    Mybatis介绍
    Java开发JDBC连接数据库
    【模板】多项式全家桶_缺斤少两
    【JOI】JOISC2020R1_T1building_构造/ntt
    【CF】codeforces_1301F_Super Jaber_最短路
    【CF】codeforces1301E_前缀和_论如何对CF的机器抱有信心
    poj 2079 Triangle
    poj 1912 A highway and the seven dwarfs
    poj 2482 Stars in Your Window
  • 原文地址:https://www.cnblogs.com/lvfeilong/p/fdfdsfdsf.html
Copyright © 2020-2023  润新知