P
Pascal
Hello
I am trying to understand the behavior of drag and drop between two labels.
I read the msdn :
Member name Description
All The data is copied, removed from the drag source, and
scrolled in the drop target.
Copy The data is copied to the drop target.
Link The data from the drag source is linked to the drop
target.
Move The data from the drag source is moved to the drop
target.
None The drop target does not accept the data.
Scroll Scrolling is about to start or is currently occurring
in the drop target.
So, this code, with a form, and 2 labels on it, should perform this behavior
: (label1.text disappears and label2.text contains "label1"), no ? (Or i
didn't understood : removed from the drag source)
###################
Public Class Form1
Dim m_AcceptMove = True
Private Sub Label1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown
If m_AcceptMove = True Then
Label1.DoDragDrop(Label1.Text, DragDropEffects.All)
Else
Label1.DoDragDrop(Label1.Text, DragDropEffects.Copy)
End If
Me.BackColor = Color.OrangeRed
End Sub
Private Sub Label2_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles Label2.DragEnter
If e.Data.GetDataPresent(DataFormats.Text) Then
If m_AcceptMove = True Then
e.Effect = DragDropEffects.All
Else
e.Effect = DragDropEffects.Copy
End If
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub Label2_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles Label2.DragDrop
If e.Data.GetDataPresent(DataFormats.Text) Then
If m_AcceptMove = True Then
e.Effect = DragDropEffects.All
Else
e.Effect = DragDropEffects.Copy
End If
Label2.Text = e.Data.GetData(DataFormats.Text).ToString
Label2.BackColor = Color.GreenYellow
Else
e.Effect = DragDropEffects.None
End If
End Sub
End Class
###################
thanks for your help
pascal
I am trying to understand the behavior of drag and drop between two labels.
I read the msdn :
Member name Description
All The data is copied, removed from the drag source, and
scrolled in the drop target.
Copy The data is copied to the drop target.
Link The data from the drag source is linked to the drop
target.
Move The data from the drag source is moved to the drop
target.
None The drop target does not accept the data.
Scroll Scrolling is about to start or is currently occurring
in the drop target.
So, this code, with a form, and 2 labels on it, should perform this behavior
: (label1.text disappears and label2.text contains "label1"), no ? (Or i
didn't understood : removed from the drag source)
###################
Public Class Form1
Dim m_AcceptMove = True
Private Sub Label1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown
If m_AcceptMove = True Then
Label1.DoDragDrop(Label1.Text, DragDropEffects.All)
Else
Label1.DoDragDrop(Label1.Text, DragDropEffects.Copy)
End If
Me.BackColor = Color.OrangeRed
End Sub
Private Sub Label2_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles Label2.DragEnter
If e.Data.GetDataPresent(DataFormats.Text) Then
If m_AcceptMove = True Then
e.Effect = DragDropEffects.All
Else
e.Effect = DragDropEffects.Copy
End If
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub Label2_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles Label2.DragDrop
If e.Data.GetDataPresent(DataFormats.Text) Then
If m_AcceptMove = True Then
e.Effect = DragDropEffects.All
Else
e.Effect = DragDropEffects.Copy
End If
Label2.Text = e.Data.GetData(DataFormats.Text).ToString
Label2.BackColor = Color.GreenYellow
Else
e.Effect = DragDropEffects.None
End If
End Sub
End Class
###################
thanks for your help
pascal