本文介绍了如何制作进度条表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码如下:
我创建一个进度条形式
my code as follow:
I create a progressbarform
public partial class fmDialog : Form
{
public int Value
{
get
{
return progressBar1.Value;
}
set
{
if (value > progressBar1.Maximum)
{
progressBar1.Value = progressBar1.Maximum;
}
else
{
progressBar1.Value = value;
}
}
}
public string NoteText
{
get
{
return label1.Text;
}
set
{
label1.Text = value;
}
}
public bool IsMaxValue
{
get
{
return progressBar1.Value == progressBar1.Maximum;
}
}
public fmDialog()
{
InitializeComponent();
}
}
来电:
Call it:
fmDialog fm = new fmDialog();
fm.Show(this);
while (!fm.IsMaxValue)
{
fm.Value += 10;
}
fm.close();
我的问题是:为什么我看不到进度条形码?我做错了什么?我想手动设置进度条的值。我该怎么办?
My question is: Why do not I see my progressbarform?Where I doing wrong?I want to manually set the value of the progressbar.What should I do?
推荐答案
BackgroundWorker work = new BackgroundWorker();
work.WorkerReportsProgress = true;
work.ProgressChanged += new ProgressChangedEventHandler(work_ProgressChanged);
work.DoWork += new DoWorkEventHandler(work_DoWork);
work.RunWorkerAsync();
}
void work_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker work = sender as BackgroundWorker;
if (sender != null)
{
for (int i = 0; i < 100; i += 10)
{
work.ReportProgress(i);
Sleep(500);
}
}
}
void work_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
}
这篇关于如何制作进度条表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!