I created the following control and added it to a form in the form design. I was curious about a couple of things. First, even in the IDE it is running and updating the time and date. Is this normal. Secondly, is this a normal way to add date/time to a user defined control?
HTML Code:Public Class MyStatusbar Inherits Windows.Forms.StatusStrip Private sslTime As New ToolStripStatusLabel Private sslDate As New ToolStripStatusLabel Private sslStatus As New ToolStripStatusLabel Private WithEvents ssTimer As New Timer Public Sub New() MyBase.New() Me.Items.AddRange(New System.Windows.Forms.ToolStripItem() {sslTime, sslDate, sslStatus}) sslTime.AutoSize = False sslTime.Name = "sslTime" sslTime.Size = New System.Drawing.Size(120, 18) sslTime.Text = Now.ToLongTimeString sslDate.AutoSize = False sslDate.Name = "sslDate" sslDate.Size = New System.Drawing.Size(120, 18) sslDate.Text = Now.ToShortDateString sslStatus.AutoSize = True sslStatus.TextAlign = ContentAlignment.MiddleCenter sslStatus.Name = "sslStatus" sslStatus.Text = "No status updates available" ssTimer.Enabled = True ssTimer.Interval = 900 End Sub Private Sub UpdateTime(ByVal sender As Object, ByVal e As System.EventArgs) Handles ssTimer.Tick sslDate.Text = Now.ToShortDateString sslTime.Text = Now.ToLongTimeString End Sub Public Sub UpdateStatus(ByVal msg As String, ByVal fnt As Font) Dim sze As Single = fnt.Size If sze > sslStatus.Height Then sze = sslStatus.Height Else sze = fnt.SizeInPoints End If sslStatus.Text = msg sslStatus.Font = New Drawing.Font(fnt.SystemFontName, fnt.SizeInPoints, fnt.Style) End Sub End Class


Reply With Quote
