This should get you started:
VB Code:
Public Class ExtendedPanel
Inherits StatusBarPanel
Public Enum AutoTextStyles
[DateTime]
[InsertKey]
End Enum
Private _AutoTextStyle As AutoTextStyles
Private _DateTimeFormat As String = "M/d/yy h:mm tt"
Private WithEvents Tmr As New Timer()
Private Const OneSecond As Integer = 1000
Public Property AutoTextStyle() As AutoTextStyles
Get
Return _AutoTextStyle
End Get
Set(ByVal Value As AutoTextStyles)
_AutoTextStyle = Value
If _AutoTextStyle = AutoTextStyles.DateTime Then
Tmr.Interval = OneSecond
Tmr.Enabled = True
Tmr.Start()
Me.Text = Format(DateTime.Now, _DateTimeFormat)
Else
Tmr.Stop()
End If
End Set
End Property
Public Property DateTimeFormat() As String
Get
Return _DateTimeFormat
End Get
Set(ByVal Value As String)
_DateTimeFormat = Value
Me.Text = Format(DateTime.Now, _DateTimeFormat)
End Set
End Property
Private Sub Tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tmr.Tick
Me.Text = Format(DateTime.Now, _DateTimeFormat)
End Sub
Public Sub New(ByVal pnl As StatusBarPanel)
Dim _Parent As StatusBar
_Parent = pnl.Parent
Me.Alignment = pnl.Alignment
Me.AutoSize = pnl.AutoSize
Me.BorderStyle = pnl.BorderStyle
Me.Icon = pnl.Icon
Me.MinWidth = pnl.MinWidth
Me.Site = pnl.Site
Me.Width = pnl.Width
'Me.Font = _Parent.Font.Clone
_Parent.Panels.Add(Me)
_Parent.Panels.Remove(pnl)
End Sub
End Class
And to use it you would make a statusbar and panel and then pass in the name of the panel that you want to replace with the extended one.
VB Code:
Dim ep As ExtendedPanel
Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ep = New ExtendedPanel(StatusBarPanel1)
ep.AutoTextStyle = ExtendedPanel.AutoTextStyles.DateTime
ep.DateTimeFormat = "h:mm:ss tt" 'just time
'ep.DateTimeFormat = "M/dd/yyyy" 'just date
End Sub