rockinup1231
09-25-2009, 11:49 PM
In an application I'm writing, there is an option for the user to import images as tiles, and for each tile, a picture box is created that contains the image they select. The newly created picture box is added and sorted automatically in a table layout panel.
The code looks like this:
Dim xtile As Integer = 0
Dim xtile1 As New PictureBox
ImportTileDialog.ShowDialog()
xtile1.Name = "srctile_" + xtile.ToString
xtile1.Height = 50
xtile1.Width = 50
xtile1.SizeMode = PictureBoxSizeMode.StretchImage
xtile1.ImageLocation = ImportTileDialog.FileName
xtile1.Visible = True
xtile1.Enabled = True
xtile1.BringToFront()
TilePanel.Controls.Add(xtile1)
xtile = xtile + 1
However, what I'd like to do and don't know how to do, is make it so these newly created controls can be clicked, and when they are clicked, make them do "something". I know that with a normal control you can add a click event for it, but since these are being created by the application I don't know how to write code each and every one of the tiles that may or may not be created.
I am using VB.NET, in Visual Basic 2008 Express.
Thanks for any help you guys can offer. :t
The code looks like this:
Dim xtile As Integer = 0
Dim xtile1 As New PictureBox
ImportTileDialog.ShowDialog()
xtile1.Name = "srctile_" + xtile.ToString
xtile1.Height = 50
xtile1.Width = 50
xtile1.SizeMode = PictureBoxSizeMode.StretchImage
xtile1.ImageLocation = ImportTileDialog.FileName
xtile1.Visible = True
xtile1.Enabled = True
xtile1.BringToFront()
TilePanel.Controls.Add(xtile1)
xtile = xtile + 1
However, what I'd like to do and don't know how to do, is make it so these newly created controls can be clicked, and when they are clicked, make them do "something". I know that with a normal control you can add a click event for it, but since these are being created by the application I don't know how to write code each and every one of the tiles that may or may not be created.
I am using VB.NET, in Visual Basic 2008 Express.
Thanks for any help you guys can offer. :t