|
-
Mar 17th, 2010, 02:57 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] If in Panels bounds?
Hello 
I have an application where I have different picture boxes which the user can drag and move.
I also have different empty pictureboxes.
What I want to do:
I want to let the user be able to drag a picturebox to one of the empty pictureboxes. Also, If the user drags a picturebox to an invalid place (outside the bounds of any of the empty pictureboxes), the dragged picture box should return to its previous location.
So what I currently have is the usual drag-drop code and on the MouseUp event, I run this code (currently only checking for one empty picturebox):
Code:
If Not pbEmpty1.Bounds.Contains(Me.PointToClient(pbRemote.Location)) Then
pbRemote.Location = OldLocation
End If
(pbEmpty1 = Empty picturebox, pbRemote = picturebox that is dragged)
But it doesn't work, it doesn't care if the picturebox is inside the bounds of the empty picturebox or not, it still returns to its previous location...
Any help please?
Thanks, Zeelia
-
Mar 17th, 2010, 03:00 PM
#2
Re: If in Panels bounds?
try this:
vb Code:
If Not pbEmpty1.Bounds.intersectswith(pbRemote.bounds) Then
pbRemote.Location = OldLocation
End If
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 17th, 2010, 03:11 PM
#3
Thread Starter
Fanatic Member
Re: If in Panels bounds?
Thank you, paul!
I've been trying to do this for quite some time now and the solution was just as easy as this, if I only had looked through the methods of 'Bounds'.
Just one more question, is the (empty) picturebox a good object to use in my case? (I just want to check if the picturebox enters the bounds)
Maybe a panel would be appropriate aswell, what do you think?
Thanks!
//Zeelia
Last edited by Zeelia; Mar 17th, 2010 at 03:16 PM.
-
Mar 17th, 2010, 03:20 PM
#4
Re: If in Panels bounds?
it depends what you're trying to do. panels are recommended as containers + pictureboxes aren't intended for that purpose.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 19th, 2010, 08:25 PM
#5
Thread Starter
Fanatic Member
Re: If in Panels bounds?
Yeah, that's just my thought, Paul.
That's why I got a bit.. curious about why I chose pictureboxes as the boundary containers...
Ah well, It does work pretty good anyways 
Thanks for the help ^.^
//Zeelia
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
|