-
I wonder if anyone can help....
I need to be able to click on a picture box created at run. The picture boxes are created using the code:
Set objFurn = frmRoom.Controls.Add("vb.PictureBox", "Furnbox" & index)
how dow i access these picture boxes by clicking on them at run-time?
-
For single controls you can use withevents as follows:
Code:
Private WithEvents objFurn As PictureBox
To use control arrays i think you have to create an invisible dummy control and use Load to load up other instances of it.
To use an array of controls, make a wrapper class for the picturebox and use withevents as above. Then Create your own events using Event statement that will raise the events you get from the picturebox into the classcollection of the wrapper classes, then raise overall events from the wrapper class that could contain the index part you usually see in control array events.
-
Code:
Private WithEvents pic As PictureBox
Private Sub Form_Load()
Set pic = Me.Controls.Add("VB.PictureBox", "Picture1")
End Sub
Private Sub pic_Click()
MsgBox "You clicked the PictureBox"
End Sub