Windows Application - SPLessons

Win App Progress Bar Control

Home > Lesson > Chapter 14
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Win App Progress Bar Control

Windows Application Progress Bar Control

shape Description

Progress Bar control is used to display the state of the application. Progress Bar control is used to know about the process of complex applications. A small application example on progress bar control. Before that, one have to know about the properties of the progress bar control.

shape Properties

The following are the properties of the progress bar control.
  • Name  Name property is used to give the name to our control. This is the common property for all the controls. Name property will give an identity to the progress bar control.The default name for the progress bar control is progressBar1.
  • Maximum and Minimum Maximum and Minimum properties are used to give the upper and lower bound values for the progress bar control.That means Maximum and Minimum properties will give a range to the progress bar control.
  • Value  Value property is used to know the progress or the current value of the progress bar control. By default, the current value will be shown in the green color.
  • RightToLeftLayout By default, RightToLeftLayout properties set to FALSE. Because, Left to right is the default direction to show the progress in the progress bar control. If one want right to left direction, then simply set the RightToLeftLayout to TRUE.
  • Cursor Cursor property is used to set the style of the cursor, which one want to display at the time of mouse over on the control happens. There are different types of cursors. The following figure shows you different values for Cursor property.
  • Marquee Animation Speed Marquee Animation Speed property is used to give the speed of the marquee in milliseconds.
These are the some important properties of the progress bar control. One can also change the appearance of the progress bar control using BackColor and ForeColor properties.

shape Example

To know learn about the progress bar control follow the below steps.

shape Step 1

Design the Registration form as shown in the below figure.

shape Step 2

Write the following code under the button click event as shown as below. [csharp] private void btnRegister_Click(object sender, EventArgs e) { if(txtName.Text!="" && txtPassword.Text!="" && txtEmail.Text!="") //Checks whether all the fields filled or not { pbRegister.Value = 100; //sets the progress bar value as 100 } else if (txtName.Text != "" || txtPassword.Text != "" || txtEmail.Text != "") //Checks whether any one of the field filled or not { pbRegister.Value = 50; //sets the progress bar value as 50 } }[/csharp]

shape Step 3

Press F5 or start to run the application. Give all the fields and click on the Register button. Then, the progress bar is as shown in the below figure.

shape Step 4

Give one or two values and click on the Register button. Then, the window will be appear as follows.