C#进度条怎么用 / C#progressBar的用法
1个回答
展开全部
//可以委托的方式来调用
progressBar1.Value = 0; //设置进度条起始
//1、定义线程,启动委托
Thread myThread = new Thread(DoData);
myThread.IsBackground = true;
myThread.Start(1000); //线程开始,1000标识进度
private delegate void DoDataDelegate(object number);
/// <summary>
/// 进行循环
/// </summary>
/// <param name="number"></param>
private void DoData(object number)
{
if (progressBar1.InvokeRequired)
{
DoDataDelegate d = DoData;
progressBar1.Invoke(d, number);
}
else
{
progressBar1.Maximum = (int)number;
for (int i = 0; i < (int)number; i++)
{
progressBar1.Value = i;
Application.DoEvents();
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询