Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Looking For a VB .NET Status Bar Example in VS2005

Posted on 2006-06-21
5
Medium Priority
?
445 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 500 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

886 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