473,320 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

RE: Drag and drop problem

Hi Steve,

I performed a test based on your description but didn't reproduce the
problem on my side.

In my test, I create a WinForm application project and add two Buttons on
the form. The code in the form is as follows:

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Button2.AllowDrop = True
Button1.AllowDrop = True
AddHandler Me.Button1.MouseMove, AddressOf ButtonMouseMove
AddHandler Me.Button1.DragEnter, AddressOf ButtonDragEnter
AddHandler Me.Button1.DragDrop, AddressOf ButtonDragDrop

AddHandler Me.Button2.MouseMove, AddressOf ButtonMouseMove
AddHandler Me.Button2.DragEnter, AddressOf ButtonDragEnter
AddHandler Me.Button2.DragDrop, AddressOf ButtonDragDrop
End Sub

Sub ButtonDragDrop(ByVal sender As Object, ByVal e As DragEventArgs)
Dim draggedbtn As Button = CType(e.Data.GetData(GetType(Button)),
Button)
Dim dropbtn As Button = CType(sender, Button)
dropbtn.Text += vbNewLine + draggedbtn.Name
Me.Controls.Remove(draggedbtn)
End Sub

Sub ButtonDragEnter(ByVal sender As Object, ByVal e As DragEventArgs)
If (e.Data.GetDataPresent(GetType(Button))) Then
e.Effect = DragDropEffects.Move
End If
End Sub

Sub ButtonMouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim btn As Button = CType(sender, Button)
If (e.Button = Windows.Forms.MouseButtons.Left) Then
btn.DoDragDrop(btn, DragDropEffects.Move)
End If
End Sub
End Class

Build and run the application. Drag&drop Button1 onto Button2. You should
see Button1 disppears and the name of the Button1 is added to the Button2's
Text and vice versa.

Is there any difference between your code and mine?
If the problem is still not solved, you'd better reproduce the problem in a
simple project and send it to me. To get my actual email address, remove
'online' from my displayed email address.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 27 '08 #1
1 1155
Hi Linda

Thanks for the reply

I tested your code and it definitely works fine

I will check my code to see where I have made a mistake

Regards
Steve

"Linda Liu[MSFT]" <v-****@online.microsoft.comwrote in message
news:Im**************@TK2MSFTNGHUB02.phx.gbl...
Hi Steve,

I performed a test based on your description but didn't reproduce the
problem on my side.

In my test, I create a WinForm application project and add two Buttons on
the form. The code in the form is as follows:

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Button2.AllowDrop = True
Button1.AllowDrop = True
AddHandler Me.Button1.MouseMove, AddressOf ButtonMouseMove
AddHandler Me.Button1.DragEnter, AddressOf ButtonDragEnter
AddHandler Me.Button1.DragDrop, AddressOf ButtonDragDrop

AddHandler Me.Button2.MouseMove, AddressOf ButtonMouseMove
AddHandler Me.Button2.DragEnter, AddressOf ButtonDragEnter
AddHandler Me.Button2.DragDrop, AddressOf ButtonDragDrop
End Sub

Sub ButtonDragDrop(ByVal sender As Object, ByVal e As DragEventArgs)
Dim draggedbtn As Button = CType(e.Data.GetData(GetType(Button)),
Button)
Dim dropbtn As Button = CType(sender, Button)
dropbtn.Text += vbNewLine + draggedbtn.Name
Me.Controls.Remove(draggedbtn)
End Sub

Sub ButtonDragEnter(ByVal sender As Object, ByVal e As DragEventArgs)
If (e.Data.GetDataPresent(GetType(Button))) Then
e.Effect = DragDropEffects.Move
End If
End Sub

Sub ButtonMouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim btn As Button = CType(sender, Button)
If (e.Button = Windows.Forms.MouseButtons.Left) Then
btn.DoDragDrop(btn, DragDropEffects.Move)
End If
End Sub
End Class

Build and run the application. Drag&drop Button1 onto Button2. You should
see Button1 disppears and the name of the Button1 is added to the
Button2's
Text and vice versa.

Is there any difference between your code and mine?
If the problem is still not solved, you'd better reproduce the problem in
a
simple project and send it to me. To get my actual email address, remove
'online' from my displayed email address.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.


Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Wang, Jay | last post by:
Hello, all, I would like to enable some text between <SPAN url="http://www.testserver.com/">WORD TO BE DRAGGED </SPAN>. I put some javascript and it will extract http://www.testserver.com/ from...
2
by: matthewmacchia | last post by:
I believe this is a Firefox bug but I was hoping someone found a workaround. I have implemented drag and drop functionality, but if I try to drag an element from a div that happens to have a div...
6
by: hemant_mishal | last post by:
Hi All, I am writting a java script library which will provide inter frame drag and drop operation. The more precise will be OLE drag and drop, which means only data will be transfered from frame...
0
by: Lauren Quantrell | last post by:
I'm trying to drop a file from Windows Explorer (or desktop, etc.) onto a field in Access2K and capture the full file path. I found an posting below that says this is possible but I cannot...
2
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put...
6
by: jojobar | last post by:
Hello, I look at the asp.net 2.0 web parts tutorial on the asp.net web site. I tried to run it under firefox browser but it did not run. If I want to use this feature in a commercial product...
8
by: benkial | last post by:
I am writing a small GUI tool in C#, and I want to experiment some fancy trick as follows: when the user click on a "OK" button, the code will initiate a "Drag and Drop" operation in the GUI itself...
2
by: Robert Zahm | last post by:
I have created a C# user control which display certain filesystem information, and allows the user to drag an drop files into and out of the control. I then placed this user form in IE using an...
14
by: maya | last post by:
I need a drag-n-drop script.. I have found one here.. http://javascript.internet.com/page-details/drag-n-drop.html each div containing an image has an id, and each image has a name, as in ...
0
by: RHSFSS | last post by:
Hi, I have a Drag and Drop registration problem (See http://www.thescripts.com/forum/thread434707.html for similar problem post), can anyone out thereadvise on the best solution? I have a .NET 2.0 ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.