I have a panel (Panel1) which serves as my container, which houses a collection of tiled pictureboxes. These pictureboxes are Dynamically Created as controls during Run-Time. I use a nested For...Next environment to accomplish the Row-Column Tiling effect. THAT IS NOT THE PROBLEM.
The problem is during the For...Next iteration (when I build the Dynamic Controls) I use:
AddHandler myPB.Click, AddressOf myPB_Click <<-- This creates a Click Event for the newly created Control.
'--------------------------------------------------------------------------------------------------------------------
Private Sub myPB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
MsgBox(Panel1.GetContainerControl.ActiveControl.Tag) <<-- Breaks here...
End Sub
'--------------------------------------------------------------------------------------------------------------------
When I dynamically create TEXTBOXES the Click event gives me the (.TAG) information, but when I Dynamically create PICTUREBOXES (which is what I need to use) the GetContainerControl.ActiveControl.Tag RETURNS a NULL VALUE (Nothing) and breaks.
Any Ideas???
Is there a better way to detect which control I am clicking and successfully returning the Index or “assigned value” like in the .TAG property??
etrain01