VB.Net - ProgressBar Control

It represents a Windows progress bar control. It is used to provide visual feedback to your users about the status of some task. It shows a bar that fills in from left to right as the operation progresses.
Let's click on a ProgressBar control from the Toolbox and place it on the form.
The main properties of a progress bar are Value, Maximum and Minimum. The Minimum and Maximum properties are used to set the minimum and maximum values that the progress bar can display. The Value property specifies the current position of the progress bar.
The ProgressBar control is typically used when an application performs tasks such as copying files or printing documents. To a user the application might look unresponsive if there is no visual cue. In such cases, using the ProgressBar allows the programmer to provide a visual status of progress.
The following are some of the commonly used properties of the ProgressBar control −
AllowDrop
Overrides Control.AllowDrop.
BackgroundImage
Gets or sets the background image for the ProgressBar control.
BackgroundImageLayout
Gets or sets the layout of the background image of the progress bar.
CausesValidation
Gets or sets a value indicating whether the control, when it receives focus, causes validation to be performed on any controls that require validation.
Font
Gets or sets the font of text in the ProgressBar.
ImeMode
Gets or sets the input method editor (IME) for the ProgressBar.
ImeModeBase
Gets or sets the IME mode of a control.
MarqueeAnimationSpeed
Gets or sets the time period, in milliseconds, that it takes the progress block to scroll across the progress bar.
Maximum
Gets or sets the maximum value of the range of the control.v
Minimum
Gets or sets the minimum value of the range of the control.
Padding 
Gets or sets the space between the edges of a ProgressBar control and its contents. 
RightToLeftLayout 
Gets or sets a value indicating whether the ProgressBar and any text it contains is displayed from right to left.
Step 
Gets or sets the amount by which a call to the PerformStep method increases the current position of the progress bar.
Style 
Gets or sets the manner in which progress should be indicated on the progress bar.
Value
Gets or sets the current position of the progress bar.v
The following are some of the commonly used methods of the ProgressBar control −
Increment 
Increments the current position of the ProgressBar control by  specified amount.
PerformStep
Increments the value by the specified step.
ResetText
Resets the Text property to its default value.
ToString
Returns a string that represents the progress bar control.
The following are some of the commonly used events of the ProgressBar control −
BackgroundImageChanged
Occurs when the value of the BackgroundImage property changes.
BackgroundImageLayoutChanged
Occurs when the value of the BackgroundImageLayout property changes.
CausesValidationChanged
Occurs when the value of the CausesValidation property changes.
Click
Occurs when the control is clicked.
DoubleClick
Occurs when the user double-clicks the control.
Enter
Occurs when focus enters the control.
FontChanged
Occurs when the value of the Font property changes.
ImeModeChanged
Occurs when the value of the ImeMode property changes.
KeyDown
Occurs when the user presses a key while the control has focus.
KeyPress
Occurs when the user presses a key while the control has focus.
KeyUp
Occurs when the user releases a key while the control has focus.
Leave
Occurs when focus leaves the ProgressBar control.
MouseClick
Occurs when the control is clicked by the mouse.
MouseDoubleClick
Occurs when the user double-clicks the control.
PaddingChanged
Occurs when the value of the Padding property changes.
Paint
Occurs when the ProgressBar is drawn.
RightToLeftLayoutChanged
Occurs when the RightToLeftLayout property changes.
TabStopChanged
Occurs when the TabStop property changes.
TextChanged
Occurs when the Text property changes.
In this example, let us create a progress bar at runtime. Let's double click on the Form and put the follow code in the opened window.
Public Class Form1
   Private Sub Form1_Load(sender As Object, e As EventArgs) _
      Handles MyBase.Load
      'create two progress bars
      Dim ProgressBar1 As ProgressBar
      Dim ProgressBar2 As ProgressBar
      ProgressBar1 = New ProgressBar()
      ProgressBar2 = New ProgressBar()
      'set position
      ProgressBar1.Location = New Point(10, 10)
      ProgressBar2.Location = New Point(10, 50)
      'set values
      ProgressBar1.Minimum = 0
      ProgressBar1.Maximum = 200
      ProgressBar1.Value = 130
      ProgressBar2.Minimum = 0
      ProgressBar2.Maximum = 100
      ProgressBar2.Value = 40
      'add the progress bar to the form
      Me.Controls.Add(ProgressBar1)
      Me.Controls.Add(ProgressBar2)
      ' Set the caption bar text of the form.  
      Me.Text = "tutorialspoint.com"
   End Sub
End Class
When the above code is executed and run using Start button available at the Microsoft Visual Studio tool bar, it will show the following window −

    63 Lectures 
     4 hours 

 Frahaan Hussain

    103 Lectures 
     12 hours 

 Arnold Higuit

    60 Lectures 
     9.5 hours 

 Arnold Higuit

    97 Lectures 
     9 hours 

 Arnold Higuit
 Print
 Add Notes
 Bookmark this page