Picturebox Help
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
2 posts
Page 1 of 1
Hello i am buildling an app that has a picture that you add and then move arround but you can add this image as many times as you like so now i am trying to make it so if you hover over one of the picutres and right click it will get removed i attempted to use this code but it does not work
Code: Select all
Just so you can see how i am adding and using the Pictureboxes here is the full Code for the Relevant part
Private Sub PictureBox_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If e.Button = MouseButtons.Right Then
Dim PB As New PictureBox
sender = Me.Controls.Remove(PB)
End If
End Sub
Code: Select all
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Dim PB As New PictureBox
PB.Size = New Size(50, 50)
PB.SizeMode = PictureBoxSizeMode.StretchImage
PB.Image = PictureBox1.Image
PB.BackColor = Color.Transparent
AddHandler PB.MouseMove, AddressOf PictureBox_MouseMove
AddHandler PB.MouseDown, AddressOf PictureBox_MouseDown
AddHandler PB.MouseUp, AddressOf PictureBox_MouseUp
Panel3.Controls.Add(PB)
cost.Text = (cost.Text + 2.51)
Label11.Text = Label11.Text + 1
End Sub
Private Sub PictureBox_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
P = e.Location
End Sub
Private Sub PictureBox_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
If e.Button = MouseButtons.Left Then
sender.Location = New Point(sender.Location.X + (e.X - P.X), sender.Location.Y + (e.Y - P.Y))
End If
End Sub
Private Sub PictureBox_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If e.Button = MouseButtons.Right Then
Dim PB As New PictureBox
sender = Me.Controls.Remove(PB)
End If
End Sub
i am trying to make it so if you hover over one of the picutres and right click it will get removedYou can use this:
Code: Select all
Private Sub PictureBox_MouseUp(sender As System.Object, e As System.Windows.Forms.MouseEventArgs)
If e.Button = MouseButtons.Right Then
Me.Controls.Remove(sender)
End If
End Sub
2 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023