c#进度条 progressBar 使用方法的小例子
using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.text;
using system.windows.forms;
using mes.core;
namespace hcmdoimport
{
public partial class processbarform : baseform
{
int processpercent = 0;
string message = "";
public string message
{
get { return message; }
set
{
message = value;
this.label1.text = message;
}
}
public int processpercent
{
get { return processpercent; }
set
{
processpercent = value;
if (processpercent >= 100)
this.close();
this.progressbar1.value = processpercent;
}
}
public processbarform()
{
initializecomponent();
}
/// <summary>
/// 更新进度
/// </summary>
/// <param name="percent">进度,小于等于100</param>
/// <param name="message">消息</param>
public void showprocess(int percent,string message)
{
this.show();
this.processpercent = percent;
this.message = message;
this.progressbar1.refresh();
this.label1.refresh();
}
private void processbarform_load(object sender, eventargs e)
{
this.cursor = cursors.waitcursor;
}
private void processbarform_formclosing(object sender, formclosingeventargs e)
{
this.cursor = cursors.default;
}
}
}