Solved

Looking For a VB .NET Status Bar Example in VS2005

Posted on 2006-06-21
5
430 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

821 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