A ProgressBar control is used to represent the progress of a lengthy operation that takes time where a user must wait for the operation to be finished.
In this article, we will see how to create a ProgressBar control in a Windows Forms application using Visual Studio 2017. We will also discuss the properties and methods defined in the ProgressBar class.
Creating a ProgressBar
We can create a ProgressBar control using a Forms designer at design-time or using the ProgressBar class in code at run-time.
Design-time
To create a ProgressBar control at design-time, you simply drag a ProgressBar control from the Toolbox and drop onto a Form in Visual Studio. After you the drag and drop, a ProgressBar is created on the Form; for example the ProgressBar1 is added to the form and looks as in Figure 1.

Figure 1
Run-time
Creating a ProgressBar control at run-time is merely a work of creating an instance of the ProgressBar class, set its properties and add the ProgressBar class to the Form controls.
The first step to create a dynamic ProgressBar is to create an instance of the ProgressBar class. The following code snippet creates a ProgressBar control object:
C# Code:
ProgressBar pBar = new ProgressBar();
VB.NET Code:
Dim pBar As New ProgressBar()
In the next step, you may set the properties of the ProgressBar control. The following code snippet sets the Location, Name, Width, and Height properties of a ProgressBar.
C# Code:
pBar.Location = new System.Drawing.Point(20, 20);
pBar.Name = "progressBar1";
pBar.Width = 200;
pBar.Height = 30;
VB.NET Code:
pBar.Location = New System.Drawing.Point(20, 20)
pBar.Name = "progressBar1"
pBar.Width = 200
pBar.Height = 30
Once the ProgressBar control is ready with its properties, the next step is to add the ProgressBar to a Form. To do so, we need to add the ProgressBar control to the form using the Controls.Add method as in the following.
C# Code:
Controls.Add(pBar);
VB.NET Code:
Controls.Add(pBar)
Setting ProgressBar Properties
After you place a ProgressBar control on a Form, the next step is to set the properties.
The easiest way to set the properties is from the Properties Window. You can open the Properties window by pressing F4 or right-clicking on a control and selecting the "Properties" menu item. The Properties window looks as in Figure 2.

Figure 2
Name
The Name property represents a unique name of a ProgressBar control. It is used to access the control in the code. The following code snippet sets and gets the name and text of a ProgressBar control.
C# Code:
PBar.Name = "ProgresBar1";
VB.NET Code:
PBar.Name = "ProgresBar1"
Positioning a ProgressBar
We can use the Location property to position a control. We can also dock a control using the Dock property.
Note: A ProgressBar can only be positioned horizontally.
The Dock property is used to set the position of a ProgressBar. It is of the type DockStyle that can have values Top, Bottom, Left, Right, and Fill. The following code snippet sets the Location, Width, and Height properties of a ProgressBar control.
C# Code:
pBar.Dock = DockStyle.Bottom;
VB.NET Code:
PBar.Dock = DockStyle.Bottom
Minimum, Maximum, and Value
The Minimum and Maximum properties define the range of a ProgressBar. The Value property represents the current value of a ProgressBar. The current value of the ProgressBar for the minimum value is the color green to show the progress of the control. We can also use the Value property to show the progress of an operation.
C# Code:
pBar.Minimum = 0;
pBar.Maximum = 100;
pBar.Value = 70;
PBar.Minimum = 0
PBar.Maximum = 100
PBar.Value = 70
A ProgressBar with a value looks as in Figure 3.

Figure 3 - ProgressBar created at Design and Run Time
RightToLeftLayout and MarqueeAnimationSpeed
The default progress of a ProgressBar is from left to right. But the ProgressBar control can also show the progress from right to left by setting RightToLeftLayout to true. The MarqueeAnimationSpeed property represents the time period, in milliseconds, that it takes the progress block to scroll across the progress bar.
Summary
In this article, we discussed how to create menus using the ProgressBar control. First we discussed how to create menus at design-time and run-time. After that we saw, how to set menus properties and click event handlers.

Micah ParkerPosted Sep 1, 2019, 2:52 AM
I am trying to make a HEX to ASCII converter, and this will be GREAT to let the users see the amount of time left. Thanks, Mahesh!
Rushi MehtaPosted Oct 8, 2018, 10:45 PM
This will be useful in the project. very useful article...
Nizar AlAssiPosted Oct 15, 2017, 1:04 PM
This is useful! Thanks.
Ramesh PalaniappanPosted Aug 18, 2016, 8:20 AM
Nice
kalu singh raoPosted Jul 7, 2016, 8:40 AM
Nice...
RajaPosted Jun 21, 2016, 6:26 AM
Good One..
Munesh SharmaPosted May 30, 2016, 1:38 PM
nice
Bhuvanesh MohankumarPosted Apr 19, 2016, 2:33 PM
Good one
Amatya AgyeyPosted Mar 24, 2016, 5:49 AM
Cool.. It will look good if we customize it.. Thanks
Asfend YarPosted Feb 22, 2016, 2:10 PM
very valuable information in this article
Asfend YarPosted Feb 22, 2016, 2:10 PM
thanks for sharing
Jithil JohnPosted Feb 16, 2016, 2:09 AM
Good one
Mr ShanawarPosted Feb 7, 2016, 6:32 AM
this is waht i was looking for , thanks for this artical
Irfan AcPosted Jan 25, 2016, 1:19 AM
good
Umarul FarookPosted Jan 22, 2016, 10:46 AM
nice, thanks
Jaco ZwartsPosted Jan 19, 2016, 1:11 AM
Nice thanks for sharing
Joe WilsonPosted Jan 14, 2016, 8:27 AM
Thank you for sharing.
Humayun Kabir MamunPosted Jan 4, 2016, 6:52 AM
Nice...
Mohamed Gani MnPosted Nov 6, 2015, 11:14 AM
Useful concept
Abhishek KumarPosted Oct 30, 2015, 4:00 AM
Nice article sir...
Waldo L.Posted Oct 23, 2015, 2:20 PM
Great ! Thanks for all, comments too !
SharadPosted Jul 22, 2015, 12:23 AM
nice..
rakesh mhatrePosted Jan 24, 2015, 12:52 AM
how to create real time progress bar while uploading file via FileUpload control
Mahdhiali JunaideenPosted Sep 15, 2014, 10:28 PM
thanks its very use full
Vithal WadjePosted Jan 24, 2013, 7:15 AM
according to my personal opinin using progress bar while submiting the data or reciving the data means the time wastage of end user
Jürgen BäurlePosted Jun 18, 2011, 9:23 AM
Great article! Here you find another nice article about how to implement a WPF progress dialog: http://www.parago.de/2011/04/how-to-implement-a-modern-progress-dialog-for-wpf-applications/
Nasir UddinPosted Apr 28, 2011, 3:09 AM
http://www.csharphelp.com/wp-content/themes/twentyten/images/headers/path.jpg
Sharique ImamPosted Sep 8, 2010, 1:51 AM
For the Below Code, I want to add a progress bar: while data inserted into the another table. It takes 1 to 2 mins, for this I want to show the progress bar till the data completely not inserted private void button1_Click_1(object sender, EventArgs e) { SqlConnection conn = null; try { conn = new SqlConnection(@"Data Source=HAIDER-IT;Initial Catalog=csoft;Integrated Security=True"); conn.Open(); SqlCommand cmd = new SqlCommand("Search",conn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 1800; cmd.Parameters.Add("@P_prd", SqlDbType.VarChar, 50).Value = "11"; cmd.Parameters.Add("@P_rep", SqlDbType.VarChar, 50).Value = "31"; cmd.Parameters.Add("@P_yy", SqlDbType.VarChar, 50).Value = "2008"; cmd.Parameters.Add("@P_mm", SqlDbType.VarChar, 50).Value = "04"; cmd.Parameters.Add("@P_HS", SqlDbType.VarChar, 50).Value = "1"; int I = cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } MessageBox.Show("Data Inserted"); }
jchbjsncPosted May 19, 2010, 5:27 AM
well
Manoj kumarPosted May 7, 2010, 10:00 AM
Hi.............. Thank you Mahesh Chand Sir for download files progrs_br1.zip. From Manoj kumar Dehradun (UA) +91-9458106336
Ali BadereddinPosted Feb 11, 2010, 8:37 PM
To understand how the C# Progress Bar works, read this post.
arun chaturvediPosted Jan 1, 2010, 5:54 AM
Thank u
Muhammad Rehan QureshiPosted Mar 21, 2009, 3:25 AM
Hi I m Rehan Qureshi.........This code solved my big problems about the working of progress bar without experience........thank for that
Sreejith ThampyeditedPosted Mar 16, 2009, 3:47 PMEdited Mar 16, 2009, 3:53 PM
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; namespace WindowsFormsApplication1 { public partial class Form1 : Form { Thread st; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { st = new Thread(new ThreadStart(load)); } public void load() { for (int i=0;i<=100;i=i+1) { progressBar1.Increment(i); statusStrip1.Text = progressBar1.Value.ToString() + "%omplete"; Thread.Sleep(500); } } private void progressBar1_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { st.Start(); } private void button2_Click(object sender, EventArgs e) { if (st.IsAlive) { st.Abort(); } } } }
Surendra GurjarPosted Jan 28, 2009, 1:17 AM
Hi, This is Surendra Gurjar, I learn from the this tutorial and it is very useful.
aissam cheikhPosted Jul 26, 2007, 1:50 PM
hello i have problem to execute progress bar with oracel connection this is my code: Timer1.Start() Try Dim cn As New OracleConnection("Password=password;User ID=dph;Data Source=creative;Persist Security Info=True") cn.Open() cn.Close() Catch ex As Exception MsgBox("sdsqdqdq") End Try Timer1.Stop() think you
Mahadevakumar GeditedPosted May 3, 2007, 7:31 AMEdited May 3, 2007, 7:45 AM
Some Clarification