Hello,
I am working a small project where I would like the user to be able to add images to a form, specifying a URL in the tag of pictureBox, so that when it is clicked. They are taken to the website they specified when adding the pictureBox.
I have a separate form for adding the URL and image so I need to pass those variables into the first form.
I can't seem to figure out how to access the Tag property of the individual pictureBox when the user clicks it. Here is my pictureBox creation code which is in the second form:
In order to have the new image linked to the PictureBox click method.Code:Dim tool As String Dim ptext As String Dim url As String url = TextBox2.Text ptext = TextBox1.Text tool = TextBox3.Text Dim pb As PictureBox = New PictureBox() pb.BackColor = Color.Transparent pb.Image = System.Drawing.Image.FromFile(ptext) pb.SizeMode = PictureBoxSizeMode.AutoSize pb.Visible = True pb.Tag = url Form1.Controls.Add(pb) Form1.FlowLayoutPanel1.Controls.Add(pb) AddHandler pb.Click, AddressOf Form1.Link_Click
Here's the Link_Click event code (in the first form) I have if it helps:
Code:Public Sub Link_Click(ByVal url As String) Dim theWebSite As String theWebSite = url Call Shell("explorer.exe " & theWebSite, vbNormalFocus) End Sub
Any help is greatly appreciated. Thank you in advance.




Reply With Quote