|
-
Oct 18th, 2007, 11:37 AM
#1
Thread Starter
PowerPoster
Progress bar animation
Just wanting a simple endless animation with 3 bars just scrolling across a simple Winforms Progress control
how can I do this?
-
Oct 18th, 2007, 01:34 PM
#2
Re: Progress bar animation
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
Code:
this.progressBar1.Style = ProgressBarStyle.Marquee;
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:
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;
}
-
Oct 18th, 2007, 02:19 PM
#3
Thread Starter
PowerPoster
Re: Progress bar animation
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
-
Oct 18th, 2007, 02:50 PM
#4
Thread Starter
PowerPoster
Re: Progress bar animation
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...
-
Oct 18th, 2007, 02:58 PM
#5
Re: Progress bar animation
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;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|