ProgressBar Control in VB.net – Properties, Methods and Events

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.

ProgressBar Control in VB.net Tutorial
ProgressBar Control in VB.net Tutorial

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 PropertiesDescription
1.AllowDropOverrides Control.AllowDrop.
2.BackgroundImageGets or sets the background image for the ProgressBar control.
3.BackgroundImageLayoutGets or sets the layout of the background image of the progress bar.
4.CausesValidationGets or sets a value indicating whether the control, when it receives focus, causes validation to be performed on any controls that require validation.
5.FontGets or sets the font of text in the ProgressBar.
6.ImeModeGets or sets the input method editor (IME) for the ProgressBar.
7.ImeModeBaseGets or sets the IME mode of a control.
8.MarqueeAnimationSpeedGets or sets the time period, in milliseconds, that it takes the progress block to scroll across the progress bar.
9.MaximumGets or sets the maximum value of the range of the control.v
10.MinimumGets or sets the minimum value of the range of the control.
11.PaddingGets or sets the space between the edges of a ProgressBar control and its contents.
12.RightToLeftLayoutGets or sets a value indicating whether the ProgressBar and any text it contains is displayed from right to left.
13.StepGets or sets the amount by which a call to the PerformStep method increases the current position of the progress bar.
14.StyleGets or sets the manner in which progress should be indicated on the progress bar.
15.ValueGets or sets the current position of the progress bar.v
Properties and Descriptions of ProgressBar Control in VB.net

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 MethodsDescription
1.ForeColorThe ForeColor method is used to reset the forecolor to its default value.
2.ToStringThe ToString method is used to display the progress bar control by returning the string.
3.IncrementIt is used to increase the current state of the progress bar control by defining the specified time.
4.PerformStepThe PerformStep method is used to increase the progress bar by setting the step specified in the ProgressBar property.
Methods and Descriptions of ProgressBar Control in VB.net

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 EventsDescription
1.BackgroundImageChangedOccurs when the value of the BackgroundImage property changes.
2.BackgroundImageLayoutChangedOccurs when the value of the BackgroundImageLayout property changes.
3.CausesValidationChangedOccurs when the value of the CausesValidation property changes.
4.ClickOccurs when the control is clicked.
5.DoubleClickOccurs when the user double-clicks the control.
6.EnterOccurs when focus enters the control.
7.FontChangedOccurs when the value of the Font property changes.
8.ImeModeChangedOccurs when the value of the ImeMode property changes.
9.KeyDownOccurs when the user presses a key while the control has focus.
10.KeyPressOccurs when the user presses a key while the control has focus.
11.KeyUpOccurs when the user releases a key while the control has focus.
12.LeaveOccurs when focus leaves the ProgressBar control.
13.MouseClickOccurs when the control is clicked by the mouse.
14.MouseDoubleClickOccurs when the user double-clicks the control.
15.PaddingChangedOccurs when the value of the Padding property changes.
16.PaintOccurs when the ProgressBar is drawn.
17.RightToLeftLayoutChangedOccurs when the RightToLeftLayout property changes.
18.TabStopChangedOccurs when the TabStop property changes.
19.TextChangedOccurs when the Text property changes.
Events and Descriptions of ProgressBar Control in VB.net

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:

ProgressBar Control in VB.net Output
ProgressBar Control in VB.net Output

Click on the Show Progress Bar button to display the progress status at run time in Windows Form.

ProgressBar Control in VB.net Display Progress Bar
ProgressBar Control Display Progress Bar

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.


Leave a Comment