C#中常使用进度条的代码
发布时间:2021-06-27 23:31:18
标签:C#中常使用进度条的代码
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Diagnostics;
using System.Threading;
namespace WindowsApplication2
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.ProgressBar progressBar2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TOD 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.progressBar2 = new System.Windows.Forms.ProgressBar();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(160, 184);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// progressBar1
//
this.progressBar1.Enabled = false;
this.progressBar1.Location = new System.Drawing.Point(32, 16);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(336, 32);
this.progressBar1.TabIndex = 2;
//
// progressBar2
//
this.progressBar2.Location = new System.Drawing.Point(32, 72);
this.progressBar2.Name = "progressBar2";
this.progressBar2.Size = new System.Drawing.Size(328, 24);
this.progressBar2.TabIndex = 3;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(48, 136);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 4;
this.textBox1.Text = "100";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(216, 136);
this.textBox2.Name = "textBox2";
this.textBox2.TabIndex = 5;
this.textBox2.Text = "100";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.SystemColors.Desktop;
this.ClientSize = new System.Drawing.Size(408, 222);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.progressBar2);
this.Controls.Add(this.progressBar1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
int outLoop = Int32.Parse(textBox1.Text);
int innerLoop = Int32.Parse(textBox2.Text);
for (int i=1;i<=outLoop;i++)
{
for (int j=i;j<=innerLoop;j++)
{
if (j%10 == 0)
{
progressBar2.Value = j;
Thread.Sleep(100);
}
}
progressBar1.Value = i;
}
}
}
}


猜你喜欢
- 本文实例讲述了C#画图之饼图折线图的实现方法,是C#程序设计中非常实用的技巧。分享给大家供大家参考。具体方法分析如下:显示图像的控件定义如下
- 在Spring Boot的众多Starter POMs中有一个特殊的模块,它不同于其他模块那样大多用于开发业务功能或是连接一些其他外部资源。
- 背景:在平时的开发中,我们时常会遇到下列场景公司的组织架构的数据存储与展示文件夹层级的数据存储与展示评论系统中,父评论与诸多子评论的数据存储
- 当遇到以下场景:其他人写的单元测试影响统计结果一些需要调用外部接口的测试暂不运行需要在非本机环境上运行一些不回滚的单元测试则有必要选择以下方
- 在 Lock 接口中,获取锁的方法有 4 个:lock()、tryLock()、tryLock(long,TimeUnit)、lockInt
- @ConfigurationProperties源码分析@ConfigurationProperties主要作用就是将prefix属性指定的
- 本文实例为大家分享了Java实现斗地主的具体代码,供大家参考,具体内容如下import java.util.ArrayList;import
- 今天可是遇到一个很简单的需求,但是却让我蛋疼了半天。滑动屏幕控制物体旋转,但是旋转的角度要在-60到60之间。乍一听这简直是小儿科啊。判断一
- 本文实例讲述了C++求四个正整数最大公约数的方法。分享给大家供大家参考,具体如下:/** 作 者: 刘同宾* 完成日期:2012 年 11
- 本文实例讲述了Android编程设置屏幕亮度的方法。分享给大家供大家参考,具体如下:使用场景最近在研究AndroidL Settings的代
- MediaQuery通常情况下,不会直接将MediaQuery当作一个控件,而是使用MediaQuery.of获取当前设备的信息,用法如下:
- SpringBoot遇到的坑@Qualifier报红今天写项目的时候@Qualifier一直报红,排查半天后面才知道原来是idea生成项目的
- 在项目开发中,经常会碰到日期处理。比如查询中,可能会经常遇到按时间段查询,有时会默认取出一个月的数据。当我们提交数据时,会需要记录当前日期,
- Android webview 从Lollipop(5.0)开始webview默认不允许混合模式,https当中不能加载http资源,需要设
- android开发中通过View的getDrawingCache方法可以达到截屏的目的,只是缺少状态栏!原始界面截屏得到的图片代码实现1.
- java实现五子棋小游戏package Gomoku;import java.awt.Toolkit;import javax.swing.
- 本方式可以获得内部存储设备地址、SD卡地址、USB设备地址,兼容性能达到99%(别问我为什么这么保证,因为是借鉴了Android设置->
- .NET中提供了读写Cookie的多种方法,Request.Cookies 是客户端通过 Cookie 标头形式由客户端传输到服务器的 Co
- 好久没有写有关UI的博客了,刚刚翻了一下之前的博客,最近一篇有关UI的博客:Android UI设计系列之自定义Dialog实现各种风格的对
- 前言相信做地图社交类APP开发的大家都知道,一般情况下,为了整体的美观和用户体验度,我们需要定制化Marker的样式。本文中实现的方式都是基