1、进度条窗体页面
2、进度条窗体相关代码
public partial class ProgressBarForm :TgGenericClass.TgDlg
{
/// <summary>
///
/// </summary>
/// <param name="formTitle"></param>
public ProgressBarForm(string formTitle)
{
InitializeComponent();
this.Text = formTitle;
}
public void ShowProgressBar()
{
this.ShowDialog();
}
/// <summary>
/// 初始化进度条最大值
/// </summary>
public int SetProgressBarMaxValue
{
set
{
this.progressBar.Maximum = value;
}
}
/// <summary>
/// 进度条初始值
/// </summary>
private bool _isProgressCancel = false;
public bool IsProgressCancel
{
get
{
return _isProgressCancel;
}
set
{
_isProgressCancel = value;
}
}
//进度条更新
public void UpdateProgressBarValue()
{
++this.progressBar.Value;
double dbTmp = this.progressBar.Value / (double)this.progressBar.Maximum;
string str = Math.Round(dbTmp * 100, 0).ToString() + "/100";
this.label1.Text = "正在处理" + str;
}
/// <summary>
/// 窗体取消事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_cancel_Click(object sender, EventArgs e)
{
try
{
_isProgressCancel = true;
}
catch (Exception ex)
{
throw new Exception();
}
}
}
}
3、使用进度条方式