Results 1 to 4 of 4

Thread: statusbar: date/time and INS/OVR

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Austria
    Posts
    52

    statusbar: date/time and INS/OVR

    does anybody know how to show date/time-information and INS/OVR in a panel of the statusbar?

    in vb6 there were panel-types for these informations... in vb.net it is only possible to set the type of a panel 'ownerdrawn'

    thanks for your help

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I believe you'd have to just set the contents of the panel manually or make your own panel that inherits from StatusBarPanel that automatically shows these things.

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    This should get you started:

    VB Code:
    1. Public Class ExtendedPanel
    2.     Inherits StatusBarPanel
    3.  
    4.     Public Enum AutoTextStyles
    5.         [DateTime]
    6.         [InsertKey]
    7.     End Enum
    8.  
    9.     Private _AutoTextStyle As AutoTextStyles
    10.     Private _DateTimeFormat As String = "M/d/yy h:mm tt"
    11.     Private WithEvents Tmr As New Timer()
    12.     Private Const OneSecond As Integer = 1000
    13.  
    14.     Public Property AutoTextStyle() As AutoTextStyles
    15.         Get
    16.             Return _AutoTextStyle
    17.         End Get
    18.         Set(ByVal Value As AutoTextStyles)
    19.             _AutoTextStyle = Value
    20.             If _AutoTextStyle = AutoTextStyles.DateTime Then
    21.                 Tmr.Interval = OneSecond
    22.                 Tmr.Enabled = True
    23.                 Tmr.Start()
    24.                 Me.Text = Format(DateTime.Now, _DateTimeFormat)
    25.             Else
    26.                 Tmr.Stop()
    27.             End If
    28.         End Set
    29.     End Property
    30.  
    31.     Public Property DateTimeFormat() As String
    32.         Get
    33.             Return _DateTimeFormat
    34.         End Get
    35.         Set(ByVal Value As String)
    36.             _DateTimeFormat = Value
    37.             Me.Text = Format(DateTime.Now, _DateTimeFormat)
    38.         End Set
    39.     End Property
    40.  
    41.     Private Sub Tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tmr.Tick
    42.         Me.Text = Format(DateTime.Now, _DateTimeFormat)
    43.     End Sub
    44.  
    45.     Public Sub New(ByVal pnl As StatusBarPanel)
    46.         Dim _Parent As StatusBar
    47.         _Parent = pnl.Parent
    48.         Me.Alignment = pnl.Alignment
    49.         Me.AutoSize = pnl.AutoSize
    50.         Me.BorderStyle = pnl.BorderStyle
    51.         Me.Icon = pnl.Icon
    52.         Me.MinWidth = pnl.MinWidth
    53.         Me.Site = pnl.Site
    54.         Me.Width = pnl.Width
    55.         'Me.Font = _Parent.Font.Clone
    56.         _Parent.Panels.Add(Me)
    57.         _Parent.Panels.Remove(pnl)
    58.     End Sub
    59.  
    60. 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:
    1. Dim ep As ExtendedPanel
    2.  
    3.     Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         ep = New ExtendedPanel(StatusBarPanel1)
    5.         ep.AutoTextStyle = ExtendedPanel.AutoTextStyles.DateTime
    6.         ep.DateTimeFormat = "h:mm:ss tt" 'just time
    7.         'ep.DateTimeFormat = "M/dd/yyyy" 'just date
    8.  
    9.     End Sub

  4. #4

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Austria
    Posts
    52
    wow... i asked for a idea and got the whole coding!

    thanks a lot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width