G
Guest
Hello,
I create multiple pictureboxe controls on a form in a For Loop and display
thumbnail pictures. I need to add a Click event to these pictureboxes. Here
is the routine that creates the pictureboxes:
----------------------------------------------------------------------------
Dim MynewPos As New Point(50, 40)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim pnt As New Point(CType(TextBox2.Text, Integer), CType(TextBox3.Text,
Integer))
CreateThem(CType(TextBox1.Text, Integer), pnt)
End Sub
Public Sub CreateThem(ByVal NumbOfPix As Integer, ByRef mypt As Point)
MynewPos = mypt
Dim i As Integer
If NumbOfPix = 0 Then
Exit Sub
End If
For i = 0 To NumbOfPix - 1
Dim PIC As New System.Windows.Forms.PictureBox
PIC.Size = New System.Drawing.Size(100, 100)
PIC.Location = MynewPos
PIC.Name = "PicBox" & i.ToString
PIC.BackColor = System.Drawing.Color.Black
PIC.Text = i
PIC.ForeColor = Color.Black
PIC.SizeMode = PictureBoxSizeMode.StretchImage
PIC.Image = Image.FromFile("C:\pic1.jpg")
MynewPos.Y += 120
Me.Controls.Add(PIC)
Next
End Sub
--------------------------------------------------------------------------------------
and here is some handler code that I don't know how to implement:
---------------------------------------------------------------------------------------
AddHandler Form1.PicBox0, _
New SomethingEventHandler(AddressOf OnClick)
Sub OnClick(ByVal sender As Object, _
ByVal args As somethingEventArgs)
'--Open a form with full sized picture
End Sub
------------------------------------------------------------------------------------
How do I implement the click event handler for each picturebox that I
create? Obviously I need to add a handler for each PicBox, like PicBox0,
PicBox1, ... so these would be in an array. How to do this?
Thanks,
Rich
I create multiple pictureboxe controls on a form in a For Loop and display
thumbnail pictures. I need to add a Click event to these pictureboxes. Here
is the routine that creates the pictureboxes:
----------------------------------------------------------------------------
Dim MynewPos As New Point(50, 40)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim pnt As New Point(CType(TextBox2.Text, Integer), CType(TextBox3.Text,
Integer))
CreateThem(CType(TextBox1.Text, Integer), pnt)
End Sub
Public Sub CreateThem(ByVal NumbOfPix As Integer, ByRef mypt As Point)
MynewPos = mypt
Dim i As Integer
If NumbOfPix = 0 Then
Exit Sub
End If
For i = 0 To NumbOfPix - 1
Dim PIC As New System.Windows.Forms.PictureBox
PIC.Size = New System.Drawing.Size(100, 100)
PIC.Location = MynewPos
PIC.Name = "PicBox" & i.ToString
PIC.BackColor = System.Drawing.Color.Black
PIC.Text = i
PIC.ForeColor = Color.Black
PIC.SizeMode = PictureBoxSizeMode.StretchImage
PIC.Image = Image.FromFile("C:\pic1.jpg")
MynewPos.Y += 120
Me.Controls.Add(PIC)
Next
End Sub
--------------------------------------------------------------------------------------
and here is some handler code that I don't know how to implement:
---------------------------------------------------------------------------------------
AddHandler Form1.PicBox0, _
New SomethingEventHandler(AddressOf OnClick)
Sub OnClick(ByVal sender As Object, _
ByVal args As somethingEventArgs)
'--Open a form with full sized picture
End Sub
------------------------------------------------------------------------------------
How do I implement the click event handler for each picturebox that I
create? Obviously I need to add a handler for each PicBox, like PicBox0,
PicBox1, ... so these would be in an array. How to do this?
Thanks,
Rich