C# 想用类库中的一个循环来控制进度条,如何使窗体中的进度条显示进度?
谢谢好心人哈!^-^ --------------------编程问答-------------------- 类库中的一个循环来控制进度条???不太明白 --------------------编程问答-------------------- 问题解决了,用委托就行了 --------------------编程问答-------------------- 委托,委托控件! --------------------编程问答-------------------- 可否发我一个例子
123115695@qq.com --------------------编程问答--------------------
给楼上的。
static void Main()--------------------编程问答-------------------- http://download.csdn.net/detail/useready/4266521
{
Application.Run(new Form1());
}
public delegate void invoke1();
private void jd()
{
this.progressBar1.Value = 0;
while(true)
{
try
{
this.progressBar1.Minimum = 0;
//System.Threading.Thread.Sleep(10);
this.button1.Text = System.Convert.ToString(int.Parse(this.button1.Text.ToString().Substring(0,this.button1.Text.ToString().IndexOf("%"))) + 1) + "%";
this.progressBar1.Value ++;
//System.Threading.Thread.Sleep(1);
Application.DoEvents();
if(this.progressBar1.Value == this.progressBar1.Maximum)
{
this.progressBar1.Maximum = this.progressBar1.Maximum * 2;
this.label1.Text = this.progressBar1.Value.ToString();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
}
private void button1_Click(object sender, System.EventArgs e)
{
this.button1.Text = "0%";
this.progressBar1.Maximum = 1;
System.Threading.Thread th = new System.Threading.Thread(new ThreadStart(ST));
try
{
th.Start();
Application.DoEvents();
return;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
this.Visible = false;
}
private void ST()
{
this.progressBar1.BeginInvoke(new invoke1(jd));
}
补充:.NET技术 , C#