form8.cs
来自「c#网络编程及应用-刘瑞新」· CS 代码 · 共 170 行
CS
170 行
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace book6_1
{
/// <summary>
/// Form8 的摘要说明。
/// </summary>
public class Form8 : System.Windows.Forms.Form
{
private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.ProgressBar progressBar2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form8()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.progressBar2 = new System.Windows.Forms.ProgressBar();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.textBox2 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// progressBar1
//
this.progressBar1.Location = new System.Drawing.Point(24, 16);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(280, 24);
this.progressBar1.TabIndex = 0;
//
// progressBar2
//
this.progressBar2.Location = new System.Drawing.Point(24, 56);
this.progressBar2.Name = "progressBar2";
this.progressBar2.Size = new System.Drawing.Size(280, 24);
this.progressBar2.TabIndex = 1;
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 104);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 16);
this.label1.TabIndex = 2;
this.label1.Text = "外循环次数";
//
// label2
//
this.label2.Location = new System.Drawing.Point(184, 104);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 16);
this.label2.TabIndex = 3;
this.label2.Text = "内循环次数";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(32, 136);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(96, 21);
this.textBox1.TabIndex = 4;
this.textBox1.Text = "";
//
// button1
//
this.button1.Location = new System.Drawing.Point(112, 176);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(72, 24);
this.button1.TabIndex = 6;
this.button1.Text = "开始计算";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(184, 136);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(96, 21);
this.textBox2.TabIndex = 5;
this.textBox2.Text = "";
this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
//
// Form8
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(312, 213);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1,
this.textBox2,
this.textBox1,
this.label2,
this.label1,
this.progressBar2,
this.progressBar1});
this.Name = "Form8";
this.Text = "Form8";
this.ResumeLayout(false);
}
#endregion
private void textBox2_TextChanged(object sender, System.EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
button1.Enabled=false;
int outLoop=Int32.Parse(textBox1.Text);
int innerLoop=Int32.Parse(textBox2.Text);
progressBar1.Maximum=outLoop;
progressBar2.Maximum=innerLoop;
for(int i=1;i<=outLoop;i++)
{
for(int j=1;j<=innerLoop;j++)
{
if(j%10==0) progressBar2.Value=j;
}
progressBar1.Value=i;
}
button1.Enabled=true;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?