Custome StatusBar control


H

Haz

We are trying to use a standard status bar on our applications, displaying
some useful information, like time, version info, etc.

So I decided to make this a custom reusable component, and put it in a
control library project. I can use it, when I debug, I see everything
working the way it is supposed to work, but it just does not display
anything on the screen.



Here is the class definition. Let me know where did I wrong!

'''''



Public Class ExtraStatusBar

Inherits System.Windows.Forms.StatusBar

Public Sub New()

MyBase.New()

Me.SetStatusBarTexts()

End Sub

Private Sub statusBarTimer_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs)

Me.Panels(1).Text = CType(DateTime.Now, String)

End Sub

Private Sub SetStatusBarTexts()

Dim statusBarTimer As New System.Timers.Timer

statusBarTimer.Interval = 100

statusBarTimer.Enabled = True

Me.Panels.Add("Ready")

Me.Panels(0).AutoSize = StatusBarPanelAutoSize.Spring

Me.Panels(0).Alignment = HorizontalAlignment.Left

Me.Panels.Add(CType(DateTime.Now, String))

Me.Panels.Add(" " + SystemInformation.UserDomainName + "\" +
SystemInformation.UserName + " on " + SystemInformation.ComputerName +
vbTab)

Dim strAppVersion As String = Application.ProductVersion

'strAppVersion = strAppVersion.Remove(strAppVersion.LastIndexOf("."),
strAppVersion.Length - strAppVersion.LastIndexOf("."))

Me.Panels.Add(strAppVersion)

'Me.Panels(1).MinWidth = 250

Me.Panels(1).AutoSize() = StatusBarPanelAutoSize.Contents

Me.Panels(2).AutoSize() = StatusBarPanelAutoSize.Contents

Me.Panels(3).AutoSize() = StatusBarPanelAutoSize.Contents

AddHandler statusBarTimer.Elapsed, AddressOf statusBarTimer_Elapsed

End Sub

Public Overrides Property Text() As String

Get

Return Me.Panels(0).Text

End Get

Set(ByVal Value As String)

Me.Panels(0).Text = Value

End Set

End Property

End Class
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top