VB.NET Technology

VB.Net Projects

VB.Net Project 1

StatusBar Control
Previous Home Next
adplus-dvertising

A status bar is commonly used to provide hints for the selected item or information about an action currently being performed on a dialog. Normally, the StatusBar is placed at the bottom of the screen, as it is in MS Office applications and Paint, but it can be located anywhere you like.

StatusBar Properties

NameAvailabilityDescription
BackgroundImageRead/WriteIt is possible to assign an image to the status bar that will be drawn in the background.
PanelsRead/Write This is the collection of panels in the status bar. Use this collection to add and remove panels.
ShowPanelsRead/Write If you want to display panels, this property must be set to true.
TextRead/WriteText

StatusBar Events

NameDescription
DrawItem Occurs when a panel that has the OwnerDraw style set needs to be redrawn. You must subscribe to this event if you want to draw the contents of a panel yourself.
PanelClick Occurs when a panels is clicked.

The StatusBarPanel Class

This class contains all the information about the individual panels in the Panels collection. The information that can be set ranges from simple text and alignment of text to icons to be displayed and the style of the panel.

Example For StatusBar

To understanding StatusBar control drag and drop status strip and make text blank and add 2toolstatuslabel and 1 toolstatusprogressbar. And drag 1textbox and 1 button,1timer control and change property according to your choice.

Code for button click on go button

Private Sub Button1_Click_1(ByVal sender As System.Object, 
	ByVal e As System.EventArgs) Handles Button1.Click
        toolStripProgressBar1.Visible = True
        toolStripStatusLabel2.Text = ""
        timer1.Enabled = True
        webBrowser1.Navigate(textBox1.Text)
        toolStripStatusLabel1.Text = textBox1.Text
    End Sub

On clicking button progress bar will show on status strip control until webpage will not open. when web page is loaded progress bar will not be display and label text will be web address and done that means page has been loaded as shown below

Code for timer Control

Private Sub Timer1_Tick(ByVal sender As System.Object, 
	ByVal e As System.EventArgs) Handles Timer1.Tick
        toolStripProgressBar1.Value = toolStripProgressBar1.Value + 10
        If toolStripProgressBar1.Value = toolStripProgressBar1.Maximum Then
            toolStripProgressBar1.Value = 0
            toolStripProgressBar1.Visible = False
            Timer1.Enabled = False
            toolStripStatusLabel2.Text = "Done"
        End If
    End Sub

Write following code on document complete event of WebbrowserControl so that progressbar stoped

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, 
	ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) 
Handles WebBrowser1.DocumentCompleted
        toolStripProgressBar1.Visible = False
    End Sub
Previous Home Next