Hi all,
I have a form in which a grid of label controls is created dynamically when the form is initialised. I want to assign an action to each of these controls, triggered when the cursor hovers over each one.
At present I am creating the controls from within the form's code, rather than in a class module (which I still don't fully understand).
Does anyone know of a way to assign such an action trigger?
I have tried to assign just a simple click event using the .OnAction property but even this doesn't seem to be accepted.
Below is the code that creates the labels ('tiles'). Can anyone point me in the right direction? If a MouseMove property cannot be assigned, I'd settle for a straight forward click.
Thanks
For n = 1 To (25 * 15)
Set tile = Me.Controls.Add("forms.label.1")
With tile
With Sheets("Align")
oRow = n + 1
tile.name = .Cells(oRow, 2).Value
tile.Tag = "RAG"
ColOff = Left(tile.name, InStrRev(tile.name, "_") - 1)
ColOff = Right(ColOff, Len(ColOff) - InStr(ColOff, "_"))
RowOff = Right(tile.name, Len(tile.name) - InStrRev(tile.name, "_"))
If (Val(ColOff) > IndNum) Or (Val(RowOff) > LocNum) Then
tile.Visible = False
Else
tile.Visible = True
tile.BackStyle = 1
tile.Left = .Cells(oRow, 3).Value
tile.Top = .Cells(oRow, 4).Value
tile.Width = 20
tile.Height = 20
tile.BorderStyle = 1
tile.BorderColor = RGB(255, 255, 255)
tile.ZOrder msoBringToFront
' tile.OnAction = "TileZoom"
ReDim Preserve TileArray(1 To n)
End If
End With
End With
Next n
Bookmarks