What is ProgressBar Control in VB.net?
The Window ProgressBar Control in VB.net is used by the user to recognize the status of some set actions.
Like downloading a sizable file from the internet, copying files, installing software, computing intricate results, and more.
In order for you to test your VB.net Code provided in this lesson, you must test the code in your code editor.
Let’s create a ProgressBar by dragging a Progress Bar control from the Toolbox and dropping it on the form.
Properties of ProgressBar Control in VB.net
The following given below are some commonly used Properties of the ProgressBar Control in VB.net.
# | ProgressBar Control in VB.net Properties | Description |
---|---|---|
1. | AllowDrop | Overrides Control.AllowDrop. |
2. | BackgroundImage | Gets or sets the background image for the ProgressBar control. |
3. | BackgroundImageLayout | Gets or sets the layout of the background image of the progress bar. |
4. | 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. |
5. | Font | Gets or sets the font of text in the ProgressBar. |
6. | ImeMode | Gets or sets the input method editor (IME) for the ProgressBar. |
7. | ImeModeBase | Gets or sets the IME mode of a control. |
8. | MarqueeAnimationSpeed | Gets or sets the time period, in milliseconds, that it takes the progress block to scroll across the progress bar. |
9. | Maximum | Gets or sets the maximum value of the range of the control.v |
10. | Minimum | Gets or sets the minimum value of the range of the control. |
11. | Padding | Gets or sets the space between the edges of a ProgressBar control and its contents. |
12. | RightToLeftLayout | Gets or sets a value indicating whether the ProgressBar and any text it contains is displayed from right to left. |
13. | Step | Gets or sets the amount by which a call to the PerformStep method increases the current position of the progress bar. |
14. | Style | Gets or sets the manner in which progress should be indicated on the progress bar. |
15. | Value | Gets or sets the current position of the progress bar.v |
Methods of ProgressBar Control in VB.net
The following given below are some commonly used Methods of the ProgressBar Control in VB.net.
# | ProgressBar Control in VB.net Methods | Description |
---|---|---|
1. | ForeColor | The ForeColor method is used to reset the forecolor to its default value. |
2. | ToString | The ToString method is used to display the progress bar control by returning the string. |
3. | Increment | It is used to increase the current state of the progress bar control by defining the specified time. |
4. | PerformStep | The PerformStep method is used to increase the progress bar by setting the step specified in the ProgressBar property. |
Events of ProgressBar Control in VB.net
The following given below are some commonly used Events of the ProgressBar Control in VB.net.
# | ProgressBar Control in VB.net Events | Description |
---|---|---|
1. | BackgroundImageChanged | Occurs when the value of the BackgroundImage property changes. |
2. | BackgroundImageLayoutChanged | Occurs when the value of the BackgroundImageLayout property changes. |
3. | CausesValidationChanged | Occurs when the value of the CausesValidation property changes. |
4. | Click | Occurs when the control is clicked. |
5. | DoubleClick | Occurs when the user double-clicks the control. |
6. | Enter | Occurs when focus enters the control. |
7. | FontChanged | Occurs when the value of the Font property changes. |
8. | ImeModeChanged | Occurs when the value of the ImeMode property changes. |
9. | KeyDown | Occurs when the user presses a key while the control has focus. |
10. | KeyPress | Occurs when the user presses a key while the control has focus. |
11. | KeyUp | Occurs when the user releases a key while the control has focus. |
12. | Leave | Occurs when focus leaves the ProgressBar control. |
13. | MouseClick | Occurs when the control is clicked by the mouse. |
14. | MouseDoubleClick | Occurs when the user double-clicks the control. |
15. | PaddingChanged | Occurs when the value of the Padding property changes. |
16. | Paint | Occurs when the ProgressBar is drawn. |
17. | RightToLeftLayoutChanged | Occurs when the RightToLeftLayout property changes. |
18. | TabStopChanged | Occurs when the TabStop property changes. |
19. | TextChanged | Occurs when the Text property changes. |
Let’s create a program to display the Progress Bar in the VB.NET Windows form.
Public Class Form1
Private Sub Button1_Click_2(sender As Object, e As EventArgs) Handles Button1.Click
ProgressBar1.Visible = True
Dim i As Integer
ProgressBar1.Minimum = 0
ProgressBar1.Maximum = 300
For i = 0 To 300 Step 1
ProgressBar1.Value = i
If i > ProgressBar1.Maximum Then
i = ProgressBar1.Maximum
End If
Next
MsgBox("Successfully Completed")
End Sub
End Class
Program Output:
Click on the Show Progress Bar button to display the progress status at run time in Windows Form.
Summary
In this article, we have discussed how to create a program for the Progress Bar in VB.net using Microsoft Visual Studio we have learned how to use and manage the different Properties, Methods, and Events of the Progress Bar in VB.net.
PREVIOUS
NEXT