This is the code for the custom control:
Public Class SPCLabel
Inherits System.Windows.Forms.UserControl
#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
'UserControl 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 lblScore As
System.Windows.Forms.Label
Friend WithEvents lblNumber As
System.Windows.Forms.Label
Friend WithEvents lblStk As
System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Me.lblScore = New
System.Windows.Forms.Label()
Me.lblNumber = New
System.Windows.Forms.Label()
Me.lblStk = New System.Windows.Forms.Label
()
Me.SuspendLayout()
'
'lblScore
'
Me.lblScore.BackColor =
System.Drawing.Color.WhiteSmoke
Me.lblScore.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle
Me.lblScore.Cursor =
System.Windows.Forms.Cursors.Hand
Me.lblScore.Font = New System.Drawing.Font
("Microsoft Sans Serif", 10.0!,
System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblScore.ForeColor =
System.Drawing.Color.ForestGreen
Me.lblScore.Location = New
System.Drawing.Point(0, 16)
Me.lblScore.Name = "lblScore"
Me.lblScore.Size = New System.Drawing.Size
(40, 16)
Me.lblScore.TabIndex = 2
Me.lblScore.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter
'
'lblNumber
'
Me.lblNumber.BackColor =
System.Drawing.Color.Silver
Me.lblNumber.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle
Me.lblNumber.Cursor =
System.Windows.Forms.Cursors.Hand
Me.lblNumber.Font = New
System.Drawing.Font("Microsoft Sans Serif", 10.0!,
System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblNumber.ForeColor =
System.Drawing.Color.DarkBlue
Me.lblNumber.Name = "lblNumber"
Me.lblNumber.Size = New
System.Drawing.Size(40, 16)
Me.lblNumber.TabIndex = 2
Me.lblNumber.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter
'
'lblStk
'
Me.lblStk.BackColor =
System.Drawing.Color.Gainsboro
Me.lblStk.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle
Me.lblStk.Cursor =
System.Windows.Forms.Cursors.Hand
Me.lblStk.Font = New System.Drawing.Font
("Microsoft Sans Serif", 8.0!,
System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblStk.ForeColor =
System.Drawing.Color.SteelBlue
Me.lblStk.Location = New
System.Drawing.Point(0, 32)
Me.lblStk.Name = "lblStk"
Me.lblStk.Size = New System.Drawing.Size
(40, 16)
Me.lblStk.TabIndex = 2
Me.lblStk.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter
'
'SPCLabel
'
Me.Controls.AddRange(New
System.Windows.Forms.Control() {Me.lblScore,
Me.lblNumber, Me.lblStk})
Me.Name = "SPCLabel"
Me.Size = New System.Drawing.Size(40, 48)
Me.ResumeLayout(False)
End Sub
#End Region
#Region " Properties "
Dim PACEStatus As String
Dim PACEPosition As Byte
Property Number() As String
Get
Number = lblNumber.Text
End Get
Set(ByVal Value As String)
lblNumber.Text = Value
End Set
End Property
Property Score() As String
Get
Score = lblScore.Text
End Get
Set(ByVal Value As String)
lblScore.Text = Value
End Set
End Property
Property STK() As String
Get
STK = lblStk.Text
End Get
Set(ByVal Value As String)
lblStk.Text = Value
End Set
End Property
Property Status() As String
Get
Status = PACEStatus
End Get
Set(ByVal Value As String)
PACEStatus = Status
End Set
End Property
Property Position() As Byte
Get
Position = PACEPosition
End Get
Set(ByVal Value As Byte)
PACEPosition = Position
End Set
End Property
Function Clear()
lblNumber.Text = ""
lblScore.Text = ""
lblStk.Text = ""
End Function
#End Region
End Class
The control is built and appears in the toolbox, and I
place it on another form with an event handler like:
Private Sub Control1_MouseEnter(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Control1.MouseEnter
MessageBox.Show("CustomControl1")
End Sub
..... and nothing happens.
Thanks,
Rob