David,
As the example shows: the "sender" parameter is the label that was clicked.
You could assign the label to a locally typed variable
' VS 2005 syntaxDim theLabel As Label = DirectCast(sender, Label)
If theLabel.BackColor = Color.Black Then
theLabel.BackColor = Color.Red
Else
theLabel.BackColor = Color.Black
End If
When you created the label you could use the Label.Tag (inherited from
Control) property to track extra information about the Label. In addition to
Label.Tag I normally use Inheritance to add additional info, via new fields
& properties to the Label control.
Public Class CustomLabel
Inherits Label
Private m_row As Integer
Private m_column As Integer
Public Property Row() As Integer
Get
Return m_row
End Get
Set(ByVal value As Integer)
m_row = value
End Set
End Property
Public Property Column() As Integer
Get
Return m_column
End Get
Set(ByVal value As Integer)
m_column = value
End Set
End Property
End Class
.Row = i
.Column = j
--
Hope this helps
Jay B. Harlow
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
David Pick said:
Thanks that worked great. Is there any way to figure out which label
was being click?