Results 1 to 5 of 5

Thread: Progress bar animation

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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?

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

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

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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...

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  5. #5
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    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
  •  



Click Here to Expand Forum to Full Width