Solved

Looking For a VB .NET Status Bar Example in VS2005

Posted on 2006-06-21
5
422 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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now