Export (0) Print
Expand All

ProgressBar Overview

.NET Framework 3.0

A progress bar is a control that an application can use to indicate the progress of a lengthy operation. It consists of a rectangle that is gradually filled as an operation progresses. This topic introduces the ProgressBar control and illustrates how to use it in C#.

This topic contains the following sections.

ProgressBar Control

ProgressBar controls are used whenever an operation takes more than a short period of time. The ProgressBar indicates to users that the operation is happening and that the application is not hung. The following graphic shows a typical ProgressBar.


Progress bar

Creating a ProgressBar

The following example shows how to create a ProgressBar. The ProgressBar is contained inside a StatusBar. The StatusBar is implemented in Extensible Application Markup Language (XAML) and the ProgressBar in C#.

<StatusBar Name="sbar" Grid.Column="0" Grid.Row="5" VerticalAlignment="Bottom" Background="Beige" >

ProgressBar progbar = new ProgressBar();
progbar.IsIndeterminate = false;
progbar.Orientation = Orientation.Horizontal;
progbar.Width = 150;
progbar.Height = 15;
Duration duration = new Duration(TimeSpan.FromSeconds(10));
DoubleAnimation doubleanimation = new DoubleAnimation(100.0, duration);
progbar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);

Notice that the progress indicated by the bar is simulated by using an animation.

For the complete sample, see ProgressBar Sample

See Also

Community Additions

© 2014 Microsoft