Just wanting a simple endless animation with 3 bars just scrolling across a simple Winforms Progress control
how can I do this?
Printable View
Just wanting a simple endless animation with 3 bars just scrolling across a simple Winforms Progress control
how can I do this?
which .net version are you coding in? For .net 2.0, you can simply set the ProgressBarStyle property to Marquee to start animation and Blocks to stop animation
With .net 1.x, you have to do it manually by increment the value using a timer. Start the timer to animate and stop the timer to stop the animation.Code:this.progressBar1.Style = ProgressBarStyle.Marquee;
Code:private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
int val = this.progressBar1.Value;
if (val < this.progressBar1.Maximum)
{
val += 1;
}
else
{
val = 0;
}
this.progressBar1.Value = val;
}
using .NET 2.0
I'm just curious...I'm sure that setting the property won't automatically scroll in a marquee style?
what exactly do I need to do to make it scroll?
I just want it to automatically keep scrolling without me doing anything but calling say a method called "Start()", then it will take care of it scrolling itself
cool thanks for that, worked great.
how would I stop the marquee, after say i press the "Stop()" button? Only way really seems to be to change the style...
Just set the ProgrssBarStyle back to Blocks to stop the animation
Code:private void button1_Click(object sender, EventArgs e)
{
//start the animation
this.progressBar1.Style = ProgressBarStyle.Marquee;
}
private void button2_Click(object sender, EventArgs e)
{
//stop the animation
this.progressBar1.Style = ProgressBarStyle.Blocks;
}