A Visual Basic Status Strip control is an object that is dragged from the VB toolbar to the Component Tray, that will display a Status bar on the bottom of your form. Most of the settings are made through the Status Strip Properties: Click the Items (Collection) Properties to add new Status Labels.

By Floyd Jay Winters 03/15/2010, 03/28/2012, 03/31/2014

 

Basic StatusStrip tips

 

1. Add a StatusStrip to the Component Tray.

2. Right-click the StatusStrip > Edit Items > [Add] items and set properties such as name. Sample names: StatusStripToolTip or ssToolTip, StatusStripDate or ssDate

 

The code below will give you an idea of what to do next:

 

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles…

    ssToolTip.Text = "Ready"

End Sub

 

Private Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs)…

    ssToolTip.Text = ToolTip1.GetToolTip(TextBox1)

End Sub

 

Then you can set ssDate and ssTime, below are some hints

On Form_Load AND in Private Sub Timer1_Tick (don't forget to set your Timer properties :-)
ssDate.Text = Today.ToShortDateString
ssTime.Text = Now.ToLongTimeString

Note the Property: RightTolLeft that can be used to postion the Status Strip.

To place items on left AND right:

Add a second status strip that will be on the left side. There is is also a property called Dock. Set Dock to "None" which will allow you to now drag it to the left corner.

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) ...
Timer1.Enabled = True

ssProgressBar1.Value = ssProgressBar1.Value + 10

 

Play with the Properties such as Text Align and Spring.

 

Video: https://sites.google.com/site/daeeducation/lectures/how-to-use-statusstrip-in-visual-basic-2010

 

(Note: There are several sections/samples on this page) 

With a Status Strip added to the Form and Selected in Designer View, change AutoSize to False in the Property Window. Click the eclipse (...) on the (Collection) property to add Items to the Status Strip, and add appropriate Labels.

With a Label added and selected in Designer View, the following Properties available in the Property Window add some additional customization:

1.    BorderStyle: Flat, Raised, Sunken, Etched, etc.

2.    BorderSides: All, Top, Right, Bottom or Left.

3.    Padding: increasing the Padding will increase the space between the Text and the border.

4.    Margin: increasing the Margin will increase the space between Labels and the space between the border and the Status Strip boundary.

5.    To Create a button on the Status Strip : Create a Label, import an Image by clicking on the Image Property eclipse (...) and set the DisplayType to Image and leave the Text property blank. Double clicking on the label will automatically create a Click Event in the Code View.

EXAMPLE CODE:

' On Load the labels on the Status Strip have their Visibility set to False.

' In this example there are statlblSomeName labels on the Status Strip - which are like lblFirstName and contains Static Text and statSomeName - which is like txtFirstName and will hold changing user input or calculated information (Dynamic Text).

Private Sub frmSB_mainEntry_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)…

  statlblTotal.Visible = False         ' label shows the text: Total: - similar to lblFirstName

  statlblAccruedTotal.Visible = False  ' label shows the text: Accrued Total, similar to lblFirstName

  statlblAccruedHours.Visible = False  ' label shows the text: Accrued Hours, similar to lblFirstName

  statTotal.Visible = False            ' label displays Calculated Total, similar to txtFirstName

  statAccruedTotal.Visible = False     ' label displays Accumulated Total, similar to txtFirstName

  statAccruedHours.Visible = False     ' label displays the Accumulated Hours, similar to txtFirstName

End Sub

' The Clear Button Turns the Visibility On, Accumulates and Formats

Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

  statlblAccruedTotal.Visible = True

  statlblAccruedHours.Visible = True

  statAccruedTotal.Visible = True

  statAccruedHours.Visible = True

  varAccrueTotal += varTotal

  varAccrueHours += varHours

  statAccruedTotal.Text = CStr(FormatNumber(varAccrueTotal, 2))

  statAccruedHours.Text = CStr(FormatNumber(varAccrueHours, 2))

End Sub

MORE EXAMPLE CODE:

' To keep a label on the Status Strip from getting too long and going off the side of the program (overflowing):

Private Sub txtCompany_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles

  statlblCompany.Visible = True

  statCompany.Visible = True

  If txtCompany.Text.Length > 8 Then

     statCompany.Text = txtCompany.Text.Substring(0, 8)

     Else

     statCompany.Text = txtCompany.Text

  End If

End Sub

 

Also see: http://msdn2.microsoft.com/en-us/library/fb25f26e(VS.80).aspx

1.     Add a StatusBar control to your form. For details, see How to: Add Controls to Windows Forms.

2.     Add a status bar panel to your StatusBar control. For details, see How to: Add Panels to a StatusBar Control.

3.     For the StatusBar control you added to your form, set the ShowPanels property to true.

4.     Add a Windows Forms Timer component to the form.

5.     Set the Timer’s Enabled property to true.

6.     Set the Timer’s Interval property of the Timer to 30000. (30,000 milliseconds= 30 Seconds)

To implement the timer to update the status bar

·         Insert the following code into the event handler of the Timer component to update the panel of the StatusBar control.

Visual Basic

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As

       StatusBar1.Panels(0).Text = Now.ToShortTimeString

End Sub