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;
}
}
}
相關文章
C#實現(xiàn)Winform動態(tài)添加菜單的方法
這篇文章主要介紹了C#實現(xiàn)Winform動態(tài)添加菜單的方法,涉及C#操作菜單的技巧,需要的朋友可以參考下2015-05-05C#實現(xiàn)的文件上傳下載工具類完整實例【上傳文件自動命名】
這篇文章主要介紹了C#實現(xiàn)的文件上傳下載工具類,結合完整實例形式分析了C#操作文件上傳與下載功能,并且還可針對上傳文件自動命名以避免服務器中的文件名重復,需要的朋友可以參考下2017-11-11