日期:2014-05-19  浏览次数:20935 次

请问高手,如何做一个加载进度条
比如我想在打开某窗体,前显示进度条(可以使用文字或图片),因为这个窗体数据可能比较大,需要一个等待过程。该怎么做?

------解决方案--------------------
:)

方法很多,例如:
1、在任务的变化处,不断改变进度条的值,这样,就能直观地显示任务进度。
2、计算大概需要多少时间,按时间来改变进度条的值。
3、做一个循环的图片,在任务进行中显示,任务完成就关闭。
……
------解决方案--------------------
<form name=loading>
  <p align=center> <font color= "#800080 " size= "2 "> 载入中,请稍等 </font> <font color= "#FFFF00 " size= "2 " face= "Arial "> ... </font>

   <input type=text name=chart size=46 style= "font-family:Arial; font-weight:bolder; color:#800080; background-color:#C0FFFF; padding:0px; border-style:none; ">
  

   <input type=text name=percent size=47 style= "color:#800080; text-align:center; border-width:medium; border-style:none; ">
   <script language= "JavaScript ">
var bar=0  <!--声明变量-->
var line= "|| "  <!--loading条的样式-->
var amount= "|| "  <!--loading条的样式-->
count() <!--直接调用count()函数-->
 
function count(){ 
bar=bar+2  <!--每次增加两个bar-->
amount =amount + line  <!--loading条每次增加两条竖线-->
document.loading.chart.value=amount  <!--刷新进展条-->
document.loading.percent.value=bar+ "% "  <!--计算出百分比-->
if (bar <99) 
{setTimeout( "count() ",100);}  <!--每0.1秒进展条加1-->
else 
{window.location = "http://www.JavaScript.com/ ";}  <!--进展条满后,显示另一个网页-->
} </script>
------解决方案--------------------
方法很多
------解决方案--------------------
主窗体先Hide掉,打开进度窗体。主窗体每完成一个进度就向进度窗体发一条消息,通知进度窗体更新进度条。
------解决方案--------------------
winform实现起来更简单吧,同意wzd24(牧野)(衣带渐宽终不悔,为伊消得人憔悴)
------解决方案--------------------
公司的一个进度条,你自己看看吧
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Threading;

namespace SM2560L
{
/// <summary>
/// movingbar 的摘要说明。
/// </summary>
public class MovingBar : System.Windows.Forms.UserControl
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Label box;
private Thread movebar;
public int xx=1;
public MovingBar()
{
// 该调用是 Windows.Forms 窗体设计器所必需的。
InitializeComponent();

// TODO: 在 InitializeComponent 调用后添加任何初始化
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
this.movebar.Abort();
components.Dispose();
}
}
base.Dispose( disposing );
}

#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.box = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// box
//
this.box.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)