Solved

Looking For a VB .NET Status Bar Example in VS2005

Posted on 2006-06-21
5
426 Views
Last Modified: 2012-06-27
I am looking for an example, in VB using VS2005, of a status bar with the status's of the CAP, Num and Scrl right justified
0
Comment
Question by:tahamilton64
  • 3
5 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 125 total points
ID: 16956121
Here is an example form.

formStatusBar.designer:

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class formStatusBar
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.StatusStrip1 = New System.Windows.Forms.StatusStrip
        Me.labelCapsLock = New System.Windows.Forms.ToolStripStatusLabel
        Me.labelNumLock = New System.Windows.Forms.ToolStripStatusLabel
        Me.labelScrollLock = New System.Windows.Forms.ToolStripStatusLabel
        Me.StatusStrip1.SuspendLayout()
        Me.SuspendLayout()
        '
        'StatusStrip1
        '
        Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.labelCapsLock, Me.labelNumLock, Me.labelScrollLock})
        Me.StatusStrip1.Location = New System.Drawing.Point(0, 354)
        Me.StatusStrip1.Name = "StatusStrip1"
        Me.StatusStrip1.Size = New System.Drawing.Size(417, 25)
        Me.StatusStrip1.TabIndex = 0
        Me.StatusStrip1.Text = "StatusStrip1"
        '
        'labelCapsLock
        '
        Me.labelCapsLock.AutoSize = False
        Me.labelCapsLock.BorderSides = CType((((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Top) _
                    Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Right) _
                    Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom), System.Windows.Forms.ToolStripStatusLabelBorderSides)
        Me.labelCapsLock.Name = "labelCapsLock"
        Me.labelCapsLock.Size = New System.Drawing.Size(50, 20)
        Me.labelCapsLock.Text = "Caps"
        Me.labelCapsLock.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'labelNumLock
        '
        Me.labelNumLock.AutoSize = False
        Me.labelNumLock.BorderSides = CType((((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Top) _
                    Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Right) _
                    Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom), System.Windows.Forms.ToolStripStatusLabelBorderSides)
        Me.labelNumLock.Name = "labelNumLock"
        Me.labelNumLock.Size = New System.Drawing.Size(50, 20)
        Me.labelNumLock.Text = "Num"
        Me.labelNumLock.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'labelScrollLock
        '
        Me.labelScrollLock.AutoSize = False
        Me.labelScrollLock.BorderSides = CType((((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Top) _
                    Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Right) _
                    Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom), System.Windows.Forms.ToolStripStatusLabelBorderSides)
        Me.labelScrollLock.Name = "labelScrollLock"
        Me.labelScrollLock.Size = New System.Drawing.Size(50, 20)
        Me.labelScrollLock.Text = "Scrl"
        Me.labelScrollLock.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'formStatusBar
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(417, 379)
        Me.Controls.Add(Me.StatusStrip1)
        Me.KeyPreview = True
        Me.Name = "formStatusBar"
        Me.Text = "Status Bar Example"
        Me.StatusStrip1.ResumeLayout(False)
        Me.StatusStrip1.PerformLayout()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
    Private WithEvents StatusStrip1 As System.Windows.Forms.StatusStrip
    Private WithEvents labelCapsLock As System.Windows.Forms.ToolStripStatusLabel
    Private WithEvents labelNumLock As System.Windows.Forms.ToolStripStatusLabel
    Private WithEvents labelScrollLock As System.Windows.Forms.ToolStripStatusLabel
End Class
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16956124
formStatusBar.vb:

Imports System.Windows.Forms
Imports System.Runtime.InteropServices

Public Class formStatusBar

    <DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True, CallingConvention:=CallingConvention.Winapi)> _
    Private Shared Function GetKeyState(ByVal keyCode As Int32) As Boolean
    End Function


    Private Sub formStatusBar_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
        Me.UpdateKeyStatus()
    End Sub

    Private Sub formStatusBar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.UpdateKeyStatus()
    End Sub

    Private Sub UpdateKeyStatus()
        If GetKeyState(Keys.CapsLock) Then
            Me.labelCapsLock.BorderStyle = Windows.Forms.Border3DStyle.Sunken
        Else
            Me.labelCapsLock.BorderStyle = Windows.Forms.Border3DStyle.Flat
        End If
        If GetKeyState(Keys.NumLock) Then
            Me.labelNumLock.BorderStyle = Windows.Forms.Border3DStyle.Sunken
        Else
            Me.labelNumLock.BorderStyle = Windows.Forms.Border3DStyle.Flat
        End If
        If GetKeyState(Keys.Scroll) Then
            Me.labelScrollLock.BorderStyle = Windows.Forms.Border3DStyle.Sunken
        Else
            Me.labelScrollLock.BorderStyle = Windows.Forms.Border3DStyle.Flat
        End If
    End Sub

End Class
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16956131
Notes:

1) Form.KeyPreview = True
2) StatusStrip labels TextAlign = MiddleRight
3) The border style for the status labels is Sunken when pressed and Flat when not pressed

Bob
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question