VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > temp > 简明python教程 >
  • C# Winform ProgressBar+Labe 联动显示进度

复制代码
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);
    }
}

或者

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();
    }
}            
 

相关教程