Sunday, 28 July 2013

Cara Membuat StatusBar atau StatusStrip Di VB.NET

Berikut Cara Membuat StatusBar atau StatusStrip Di VB.NET Saya Menggunakan Visual Studio 2010
Saya Membuat nya langsung dengan coding tanpa bantuan toolbox , codingan taro di form load

Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Membuat Status bar nya
        Dim statusBarMain As New StatusBar
        statusBarMain.Name = "StatusBar"
        statusBarMain.ShowPanels = True

'MEMBUAT PANEL USER LOGIN

        Dim statusBarUser = New StatusBarPanel
        statusBarUser.Name = "StatusBarUser"
        statusBarUser.Text = flogin.txtusername.Text
        statusBarUser.AutoSize = StatusBarPanelAutoSize.Contents
        statusBarMain.Panels.Add(statusBarUser)

'MEMBUAT PANEL TANGGAL

        Dim statusBarDate = New StatusBarPanel
        statusBarDate.Name = "StatusBarDate"
        statusBarDate.Text = FormatDateTime(Now(), DateFormat.ShortDate)
        statusBarDate.AutoSize = StatusBarPanelAutoSize.Contents
        statusBarMain.Panels.Add(statusBarDate)

'MEMBUAT PANEL JAM

        Dim statusBarTime = New StatusBarPanel
        statusBarTime.Name = "StatusBarTime"
        statusBarTime.Text = FormatDateTime(Now(), DateFormat.LongTime)
        statusBarTime.AutoSize = StatusBarPanelAutoSize.Contents
        statusBarMain.Panels.Add(statusBarTime)

'MEMBUAT PANEL CAPS LOCK ON/OFF

        Dim statusBarCAPS = New StatusBarPanel
        statusBarCAPS.Name = "StatusBarCAPS"

        If My.Computer.Keyboard.CapsLock = 1 Then
            statusBarCAPS.Text = "CAPS ON"
        Else
            statusBarCAPS.Text = "CAPS OFF"
        End If

        statusBarCAPS.AutoSize = StatusBarPanelAutoSize.Contents
        statusBarMain.Panels.Add(statusBarCAPS)

'MEMBUAT PANEL NUM LOCK ON/OFF

        Dim statusBarNUMS = New StatusBarPanel
        statusBarNUMS.Name = "StatusBarNUMS"

        If  My.Computer.Keyboard.NumLock = 1 Then
            statusBarNUMS.Text = "NumLock ON"
        Else
            statusBarNUMS.Text = "NumLock OFF"
        End If

        statusBarNUMS.AutoSize = StatusBarPanelAutoSize.Contents
        statusBarMain.Panels.Add(statusBarNUMS)

        ' TAMBAHKAN SEMUA KONTROL KE FORM
        Me.Controls.Add(statusBarMain)

'REFRESH STATUSBAR NYA DENGAN TIMER
Timer1.Start()
    End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim status As StatusBar = CType(Me.Controls.Find("statusBar", True)(0), StatusBar)

        status.Panels("statusBarDate").Text = FormatDateTime(Now(), DateFormat.ShortDate)
        status.Panels("statusBarTime").Text = FormatDateTime(Now(), DateFormat.LongTime)

        If My.Computer.Keyboard.NumLock = 1 Then
            status.Panels("statusBarNUMS").Text = "NumLock ON"
        Else
            status.Panels("statusBarNUMS").Text = "NumLock OFF"
        End If

        If My.Computer.Keyboard.CapsLock = 1 Then
            status.Panels("statusBarCAPS").Text = "CAPS ON"
        Else
            status.Panels("statusBarCAPS").Text = "CAPS OFF"
        End If

    End Sub


Perhatian: Yuk Baca Artikel bagus di Nurul Musthofa

Artikel Terkait

1 comment:

 

Network

Pesan

Semoga situs ini bermanfaat