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.