I am trying to allow a user to drag a Picturebox control around the
form and drop it in a new location.
Currently, I was trying to use the following:
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If e.Button() = Windows.Forms.MouseButtons.Left Then
sender.Location = e.Location
Debug.Print(sender.name.ToString &
sender.location.ToString)
sender.Refresh()
Me.Refresh()
End If
End Sub
Originally, I didn't have the Refresh calls in there but added them
because the object appears to flicker between 2 locations. I then
added the Debug.Print to see the following:
PictureBox1{X=65,Y=46}
PictureBox1{X=77,Y=28}
PictureBox1{X=65,Y=46}
PictureBox1{X=77,Y=28}
PictureBox1{X=65,Y=46}
PictureBox1{X=77,Y=28}
PictureBox1{X=65,Y=46}
PictureBox1{X=77,Y=28}
If I press the left button down and move the PictureBox even a little
bit and hold the mouse still, the box flashes between the 2 locations.
Is there something I missing or a better way to accomplish this?
Thanks,
Michael 4 2225
dont use sender, use the picturebox name because "sender" is only a copy of
the picturebox, since it has the "byval" tag to it, so set the picturebox
name to the location and it should work
--
-iwdu15
"iwdu15" <jmmgoalsteratyahoodotcom> schrieb dont use sender, use the picturebox name because "sender" is only a copy of the picturebox, since it has the "byval" tag to it, so set the picturebox name to the location and it should work
No, Sender does point to the Picturebox. The argument is ByVal, thus it does
contain a copy, but only a copy of the reference. A Picturebox is a
reference type.
Armin
Using the API bitblt, you can copy the picture box from the picture box
graphics object into a bitmap then create a cursor from the bitmap when the
mouse down event is pressed. When the Mouse up event occurs, you can then
reposition the picture box to the new coordinates..it works great.
--
Dennis in Houston
"Ikey" wrote: I am trying to allow a user to drag a Picturebox control around the form and drop it in a new location.
Currently, I was trying to use the following:
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If e.Button() = Windows.Forms.MouseButtons.Left Then sender.Location = e.Location Debug.Print(sender.name.ToString & sender.location.ToString) sender.Refresh() Me.Refresh() End If
End Sub
Originally, I didn't have the Refresh calls in there but added them because the object appears to flicker between 2 locations. I then added the Debug.Print to see the following:
PictureBox1{X=65,Y=46} PictureBox1{X=77,Y=28} PictureBox1{X=65,Y=46} PictureBox1{X=77,Y=28} PictureBox1{X=65,Y=46} PictureBox1{X=77,Y=28} PictureBox1{X=65,Y=46} PictureBox1{X=77,Y=28}
If I press the left button down and move the PictureBox even a little bit and hold the mouse still, the box flashes between the 2 locations. Is there something I missing or a better way to accomplish this?
Thanks, Michael
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Chua Wen Ching |
last post by:
Hi there.
My maths is kind of bad, and i really need to guides.
Just say i am allowed to create mouseevents in a
picturebox.
There is a prefix image1 (x = 10, y = 10), image2 (x = 10,
y =...
|
by: Trythat |
last post by:
How can I drag and drop a image from Internet Explorer (IE or Mozilla etc) to
my PictureBox, I can drag a image from a window, whereby I use a string which
contains the filename, but this doesn't...
|
by: Boni |
last post by:
Dear all,
I need to drag node from a tree view on a picturebox.
I made following:
AllowDrop in picturebox.
Handle picturebox drop events. But those events never happen. My feeling is
that...
|
by: pamelafluente |
last post by:
Hi,
I have a PictureBox on a form. I wish to drag the image exposed by the
PictureBox through the property "image" to a window of Windows
Explorer. The new file will have a name assigned by the...
|
by: TarheelsFan |
last post by:
I am having problems with drag and drop into a listview. I am able to
drag and drop items from within the listview, as well as drag items
from the listview and drop into a picturebox. However, I...
|
by: Steven Garrad |
last post by:
Hi All,
I have a pictureBox control inside of a panel control. The pictureBox is
larger than the panel control and I have the panel control set true for
AutoScroll so the panel displays scrolling...
|
by: Truevision .Net |
last post by:
Hi,
I have a problem with drag and drop functionality when it comes to
dropping pictures from sources like for example internet explorer and
the webbrowser control. Dragging and dropping from...
|
by: Steve Bottoms |
last post by:
Hi, all! Using VB .Net 2k5 under Vista Business...
I'm trying to put together a very basic drag-and-drop for file
copying, and can't seem to get DragDrop events (Form, PictureBox,
TextBox, etc)...
|
by: mohanavel |
last post by:
Hi,
My problem is.
I have two user control that holds one label and one Picture box.
Say user Controls A and B.
A - has DoDragDrop(this, DragDropEffects.Copy) method. its called...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |