Click here to Skip to main content
15,895,746 members
Articles / Programming Languages / Visual Basic

LEDClock - Windows Forms Composite Control

Rate me:
Please Sign up or sign in to vote.
4.61/5 (15 votes)
4 Jun 20023 min read 153.3K   1.1K   39  
This article explains how to build Popup editor and link it to an appropriate property in Properties Window
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents LedClock1 As WinControls.LEDClock
    Friend WithEvents btnStop As System.Windows.Forms.Button
    Friend WithEvents btnStart As System.Windows.Forms.Button
    Friend WithEvents btnReset As System.Windows.Forms.Button
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents txtSet As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.LedClock1 = New WinControls.LEDClock()
        Me.btnStop = New System.Windows.Forms.Button()
        Me.btnStart = New System.Windows.Forms.Button()
        Me.btnReset = New System.Windows.Forms.Button()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.txtSet = New System.Windows.Forms.TextBox()
        Me.SuspendLayout()
        '
        'LedClock1
        '
        Me.LedClock1.BackColor = System.Drawing.SystemColors.Control
        Me.LedClock1.ForeColor = System.Drawing.Color.SteelBlue
        Me.LedClock1.Location = New System.Drawing.Point(136, 56)
        Me.LedClock1.Name = "LedClock1"
        Me.LedClock1.Size = New System.Drawing.Size(256, 32)
        Me.LedClock1.TabIndex = 0
        Me.LedClock1.Time = "08:56:55"
        '
        'btnStop
        '
        Me.btnStop.BackColor = System.Drawing.SystemColors.Control
        Me.btnStop.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnStop.ForeColor = System.Drawing.Color.SteelBlue
        Me.btnStop.Location = New System.Drawing.Point(16, 16)
        Me.btnStop.Name = "btnStop"
        Me.btnStop.Size = New System.Drawing.Size(488, 23)
        Me.btnStop.TabIndex = 1
        Me.btnStop.Text = "Stop clock"
        '
        'btnStart
        '
        Me.btnStart.BackColor = System.Drawing.SystemColors.Control
        Me.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnStart.ForeColor = System.Drawing.Color.SteelBlue
        Me.btnStart.Location = New System.Drawing.Point(16, 112)
        Me.btnStart.Name = "btnStart"
        Me.btnStart.Size = New System.Drawing.Size(488, 23)
        Me.btnStart.TabIndex = 1
        Me.btnStart.Text = "Start clock"
        '
        'btnReset
        '
        Me.btnReset.BackColor = System.Drawing.SystemColors.Control
        Me.btnReset.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnReset.ForeColor = System.Drawing.Color.SteelBlue
        Me.btnReset.Location = New System.Drawing.Point(16, 48)
        Me.btnReset.Name = "btnReset"
        Me.btnReset.Size = New System.Drawing.Size(88, 56)
        Me.btnReset.TabIndex = 1
        Me.btnReset.Text = "Reset time"
        '
        'Button1
        '
        Me.Button1.BackColor = System.Drawing.SystemColors.Control
        Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.Button1.ForeColor = System.Drawing.Color.SteelBlue
        Me.Button1.Location = New System.Drawing.Point(416, 48)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(88, 40)
        Me.Button1.TabIndex = 1
        Me.Button1.Text = "Set time"
        '
        'txtSet
        '
        Me.txtSet.BackColor = System.Drawing.SystemColors.Window
        Me.txtSet.Location = New System.Drawing.Point(416, 88)
        Me.txtSet.Name = "txtSet"
        Me.txtSet.Size = New System.Drawing.Size(88, 20)
        Me.txtSet.TabIndex = 2
        Me.txtSet.Text = ""
        Me.txtSet.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(520, 149)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtSet, Me.btnStop, Me.LedClock1, Me.btnStart, Me.btnReset, Me.Button1})
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
        Me.LedClock1.Stop()
    End Sub

    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
        Me.LedClock1.Start()
    End Sub

    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
        Me.LedClock1.Time = "00:00:00"
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.LedClock1.Time = Me.txtSet.Text
    End Sub

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions