using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace progBarApp
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Timers.Timer timer1;
private System.Windows.Forms.ProgressBar progressBar1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.timer1 = new System.Timers.Timer();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
this.SuspendLayout();
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 1000;
this.timer1.SynchronizingObject = this;
this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
//
// progressBar1
//
this.progressBar1.Location = new System.Drawing.Point(40, 88);
this.progressBar1.Maximum = 200;
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(200, 20);
this.progressBar1.Step = 20;
this.progressBar1.TabIndex = 1;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(280, 189);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.progressBar1});
this.Name = "Form1";
this.Text = "使用进度条";
((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (progressBar1.Value >= 200 )
{
progressBar1.Value = 0;
return;
}
progressBar1.Value += 20;
}
}
}