Solved

Looking For a VB .NET Status Bar Example in VS2005

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

11 Experts available now in Live!

Get 1:1 Help Now