|
-
Apr 19th, 2009, 03:36 AM
#1
Thread Starter
New Member
-
Apr 19th, 2009, 07:50 AM
#2
Re: Picturebox and other questions
If you dont know what I mean then just forgot it but please try.
I'd love to help but I've honestly no idea what you are trying to say with your diagrams.
I understand your code, that you are creating a new picturebox and the position on the form the user has clicked, and are trying to load the picture specified by the filename in a textbox.
I have no idea what the diagrams are supposed to mean.
In order to remove your new picture box when the user right-clicks on it you need to create a routine to handle the mouse-down event and hook it up to your new picture box using AddHandler,
ie create a routine :
Code:
Private Sub RemovePictureBox(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If e.Button = Windows.Forms.MouseButtons.Right Then
CType(sender, PictureBox).Dispose()
End If
End Sub
and in your code which creates the new picture box add the following line :
Code:
AddHandler pb.MouseDown, AddressOf RemovePictureBox
-
Apr 19th, 2009, 09:09 AM
#3
Thread Starter
New Member
-
Apr 19th, 2009, 01:23 PM
#4
Re: Picturebox and other questions
Sorry... still not much the wiser, unless what you are saying that the pixture boxes must "snap" to a grid which has cells 32x32 pixels in dimension?
If that is what you mean then you need to ditch the line
Code:
pb.Location = e.Location
and replace it with something like this
Code:
pb.Left = Int(e.X / 32) * 32
pb.Top = Int(e.Y / 32) * 32
Problem though : you would potentially end up with multiple picture boxes in the same location though which I'd imagine would be something you want to avoid.
It might be easier to start off with a two dimensional array of picture boxes to start with rather than creating them dynamically, and that way you can just calculate the X and Y position within the grid and reference the required picture box.
Otherwise I guess you'll need to loop through the form's control collection and look to see if it already contains a picture box with the co-ordinates you are about to use, and only create the new picture box if there is no match.
-
Apr 19th, 2009, 01:38 PM
#5
Thread Starter
New Member
Re: Picturebox and other questions
THANKS IT WORKED!!! Rep from me. You should really learn me how to explain something
-
Apr 19th, 2009, 02:00 PM
#6
Thread Starter
New Member
Re: Picturebox and other questions
But how do I do that I can example fill it all out you know that I click on click and then the hole screen is filled out with a 32x32 image?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|