日期:2014-05-18  浏览次数:20815 次

新手请教:如何实现progressbar这样的效果


想在radiobutton1、radiobutton2、radiobutton3之间切换时,
想实现这样的progressbar效果


在设计界面,添加了一个timer以及写了代码


C# code
public partial class frmPross : Form
    {
        public frmPross()
        {
            InitializeComponent();
            timer1.Enabled = true;
            progressBar1.Visible = true;
        }

private void timer1_Tick(object sender, EventArgs e)
        {
            if (this.progressBar1.Value < this.progressBar1.Maximum)
            {
                this.progressBar1.PerformStep();
            }
            else if (this.progressBar1.Value == this.progressBar1.Maximum)
            {
                this.progressBar1.Value = 0;
            }
        }



但是,在调试的时候,却是这样的效果



我错在哪里呢?怎么才能实现这样的效果呢? 谢谢

------解决方案--------------------
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

progressBar1.Visible = true;

}

private void timer1_Tick(object sender, EventArgs e)
{
textBox1.Text = this.progressBar1.Value.ToString();
if (this.progressBar1.Value < this.progressBar1.Maximum)
{
this.progressBar1.PerformStep();
//this.progressBar1.Value += 10;
}
else if (this.progressBar1.Value == this.progressBar1.Maximum)
{
this.progressBar1.Value = 0;
timer1.Stop();

}

}

private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
timer1.Start();
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
timer1.Start();
}

private void radioButton3_CheckedChanged(object sender, EventArgs e)
{

timer1.Start();
}
}
------解决方案--------------------
ProgressBar 有一个属性 Style 设置为 Marquee ,效果就是来回滚了
------解决方案--------------------
探讨
引用:

ProgressBar 有一个属性 Style 设置为 Marquee ,效果就是来回滚了


只滚动一次呢?滚动完毕,radiobutton1 与 radiobutton2 之间的切换完毕