Elements / Status Bar
Status Bar

The C1StatusBar control appears like a horizontal bar at the bottom of the Forms window. The StatusBar can display various kinds of status information in an application window.

Statusbar

Adding StatusBar at Design-Time

The C1StatusBar control is a separate control and can be added at design-time from the Toolbox. When dropped on the Forms, C1StatusBar gets docked at the bottom. Items can be added to the left and right pane of the StatusBar by using the dual floating toolbars or the collection editors in the Properties window.

Adding StatusBar via Code

The StatusBar control can also be added to the form programmatically. The items can be added to the left pane and right pane of the StatusBar using the LeftPaneItems and RightPaneItems properties of the C1StatusBar class.

Public Class Form1

    Private statusBar As C1StatusBar
    Private _percents As Integer() = New Integer() {10, 20, 30, 40, 50, 60,
        70, 80, 90, 100, 120, 150,
        200, 250, 300, 400, 700, 1000}

    Public Sub New()
        InitializeComponent()
        'Add Status Bar to the Ribbon Control
        AddStatusBar(Me)
    End Sub

    Public Sub AddStatusBar(form1 As Form1)
        ' Create and Add a Status Bar
        statusBar = New C1StatusBar()
        statusBar.Width = 150

        ' Create button to show the percentage value
        Dim zoomButton As New RibbonButton(Nothing, Image.FromFile("images\zoomButton.png"))
        Dim wordcountLabel As New RibbonLabel()
        wordcountLabel.Text = "0 words"
        Dim charcountLabel As New RibbonLabel()
        charcountLabel.Text = "0 chars"

        ' Add TextChanged event handler
        AddHandler RichTextBox1.TextChanged, AddressOf RichTextBox1_TextChanged

        ' Create a Ribbon Track Bar
        Dim zoomTrackBar As New RibbonTrackBar()
        zoomTrackBar.Minimum = 0
        zoomTrackBar.Maximum = 17
        zoomTrackBar.StepFrequency = 1

        ' Add Event Handler
        AddHandler zoomTrackBar.ValueChanged, AddressOf ZoomTrackBar1_ValueChanged

        ' Add items to the right and left panels
        statusBar.RightPaneItems.Add(zoomTrackBar)
        statusBar.RightPaneItems.Add(New RibbonLabel("10%"))
        statusBar.LeftPaneItems.Add(wordcountLabel)
        statusBar.LeftPaneItems.Add(charcountLabel)

        ' Add Status Bar to the Main Form
        Me.Controls.Add(statusBar)
    End Sub

    Private Sub ZoomTrackBar1_ValueChanged(sender As Object, e As EventArgs)
        Dim zoomBar As RibbonTrackBar = DirectCast(sender, RibbonTrackBar)
        Dim index = zoomBar.Value
        Dim zf As Integer = _percents(index)
        Dim zoomLabel = DirectCast(statusBar.RightPaneItems(1), RibbonLabel)
        zoomLabel.Text = zf.ToString() & "%"
        Me.RichTextBox1.ZoomFactor = zf / 100.0F
    End Sub

    Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs)
        Dim charcountLabel As RibbonLabel = DirectCast(statusBar.LeftPaneItems(0), RibbonLabel)
        Dim wordcountLabel As RibbonLabel = DirectCast(statusBar.LeftPaneItems(1), RibbonLabel)
        charcountLabel.Text = RichTextBox1.TextLength.ToString() & " chars"
        wordcountLabel.Text = RichTextBox1.Text.Split(New Char() {" "c}, StringSplitOptions.RemoveEmptyEntries).Length.ToString() & " words"
    End Sub

End Class