c#,winform,progressbar+labe,联动显示进度
2008-05-15 11:12 Virus-BeautyCode 阅读(22613) 评论(9) 编辑 收藏 举报 private void btnCount_Click(object sender, EventArgs e)
{
label1.Visible=true;
progressBar.Visible = true;
progressBar.Minimum = 0;
progressBar.Maximum = ds.Tables["表"].Rows.Count;
progressBar.BackColor = Color.Green;
for (int i = 0; i < ds.Tables["表"].Rows.Count; i++)
{
progressBar.Value++;
Application.DoEvents();
this.label1.Text = Convert.ToString(progressBar.Value);
}
}
或者
{
label1.Visible=true;
progressBar.Visible = true;
progressBar.Minimum = 0;
progressBar.Maximum = ds.Tables["表"].Rows.Count;
progressBar.BackColor = Color.Green;
for (int i = 0; i < ds.Tables["表"].Rows.Count; i++)
{
progressBar.Value++;
Application.DoEvents();
this.label1.Text = Convert.ToString(progressBar.Value);
}
}
或者
private void btnCount_Click(object sender, EventArgs e)
{
label1.Visible=true;
progressBar.Visible = true;
progressBar.Minimum = 0;
progressBar.Maximum = ds.Tables["表"].Rows.Count;
progressBar.BackColor = Color.Green;
for (int i = 0; i < ds.Tables["表"].Rows.Count; i++)
{
progressBar.Value++;
Application.DoEvents();
this.label1.Text = Convert.ToString(progressBar.Value);this.label1.Refresh();
}
}