c#进度条 progressBar 使用方法的小例子

时间:2021-05-20

复制代码 代码如下:
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;
}
}
}

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章