At class level in your form:
Private m_pictureboxes As New ArrayList()
In the Click event handler of your button:
Dim _pic As New PictureBox
_pic.Location = New System.Drawing.Point(<x>, <y>)
_pic.Size = New System.Drawing.Size(<w>, <h>)
' set any other properties as required
' wire up the desired event handlers
AddHandler _pic.<event>, AddressOf <event_handler>
Me.Controls.Add(_pic)
m_pictureboxes.Add(_pic)
where:
<xand <yare the coordinates of the desired iniial position
<wand <hare the width and height values for the desired size
<eventis the desired event
<event_handleris the desired event hander (predefined)
e.g.
Private Sub PictureBox_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
CType(sender, PictureBox).BackColor = Color.CadetBlue
End Sub
If you 'add' 3 pictureboxes by clicking the button three times and then
click a picturebox, it's background colour will change.
Obviously you will have to implement a mechanism for varying the <xand <y>
values otherwise all the pictureboxes will be drawn in the same place.
<to**@mkkbb.f9.co.ukwrote in message
news:11**********************@31g2000cwt.googlegro ups.com...
Hi there,
Is it possible to create an array of picturebox controls during
run-time. I wish to create a new image/picturebox everytime a user
clicks the button on a form, and they need to be objects so that the
user can move/drag them around.
The only examples I can find dont work as I am using VB Express (2005?)
and the examples are writting in VB6.
Is anyone able to help please?
Toby.