| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1052 人关注过本帖
标题:[讨论]怎样改成一个自动的进展条?
只看楼主 加入收藏
花自飘零水自流
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-4-28
收藏
 问题点数:0 回复次数:5 
[讨论]怎样改成一个自动的进展条?

下面是一个进展条的代码:
public void UpdatePercentText()
{
int nPercent,nRange;
nRange=progressBar1.Maximum-progressBar1.Minimum;
nPercent=100*progressBar1.Value / nRange;
label1.Text=String.Concat(nPercent.ToString(),"%" );
}
private void Form1_Load(object sender, System.EventArgs e)
{
progressBar1.Maximum=100;
progressBar1.Minimum=0;
progressBar1.Value=0;
progressBar1.Step=1;
UpdatePercentText();
}

private void button1_Click(object sender, System.EventArgs e)
{

int nStep=-progressBar1.Step;
progressBar1.Increment(nStep);
UpdatePercentText();
}

private void button2_Click(object sender, System.EventArgs e)
{
progressBar1.PerformStep();
UpdatePercentText();
}
这是一个手动的,点击进展一个步长,我现在想让它能自动进展的,并进展到100%时弹出下载完毕对话框,这样能实现吗?又在那里怎样改呢??请各位高手多多指点!

搜索更多相关主题的帖子: 自动 进展 nPercent nRange void 
2006-04-28 07:36
天气预报不准
Rank: 1
等 级:新手上路
帖 子:200
专家分:0
注 册:2006-3-16
收藏
得分:0 

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;
}
}
}


哎!发型有点乱。。。。。。
2006-04-28 17:26
花自飘零水自流
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-4-28
收藏
得分:0 
非常感谢哦~!
你的那个代码我运行了,就是你的窗体和我的不同
我的是有两个button按钮 一个“关闭”,一个“确定”,我想要点击“确定”就自动进展,要实现那样又怎么改呢~!
能告诉我下吗??能否在我的那些代码上增改~!

切记人生四千万:千万不要去触碰脆弱的爱情,千万不要虚度年华,千万要爱护自己, 千万要懂得珍惜 !
2006-04-28 21:30
花自飘零水自流
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-4-28
收藏
得分:0 
我是一个初学者~!请大家多多指点~!
我很喜欢C#编程~!她就是我的最爱!
支持我吧!同时也非常感谢各位大哥大姐的回帖咯~!
[IMG]http://olb.photo.qq.com/?pid=BE950D02D24C1828BA030CE2C9C34FE5[/IMG]

切记人生四千万:千万不要去触碰脆弱的爱情,千万不要虚度年华,千万要爱护自己, 千万要懂得珍惜 !
2006-04-28 22:42
xxxxx52
Rank: 4
等 级:贵宾
威 望:13
帖 子:689
专家分:0
注 册:2006-4-30
收藏
得分:0 
学习学习

好的资料下载网站http:///in.asp?id=xuelion2006 嘿嘿帮点一下拉~
2006-04-30 14:58
花自飘零水自流
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-4-28
收藏
得分:0 

[IMG]C:\Documents and Settings\hbw\My Documents\My Pictures\{4BE67688-39E4-4934-B976-E33A0DFD1ED9}.BMP[/IMG]

就是这样的窗体~!


切记人生四千万:千万不要去触碰脆弱的爱情,千万不要虚度年华,千万要爱护自己, 千万要懂得珍惜 !
2006-05-14 17:07
快速回复:[讨论]怎样改成一个自动的进展条?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012136 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved