handling drag & drop
Thanks
Thanks
The line and shapes are light weight windowless controls and therefore don't support drag/drop. However, the ShapeContainer does. The ShapeContainer is an invisible container that the shapes are hosted in.
To handle drag and drop you will just need to allow dropping on the shapecontainer and test to see if the drop occurred on a shape. If so then you can take whatever action you wish. As this simple example demonstrates:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ShapeContainer1.AllowDrop = True
End Sub
Private Sub ShapeContainer1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ShapeContainer1.DragEnter
e.Effect = DragDropEffects.Copy
End Sub
Private Sub ShapeContainer1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ShapeContainer1.DragDrop
Dim s As Microsoft.VisualBasic.PowerPacks.Shape = ShapeContainer1.GetChildAtPoint(New Point(e.X, e.Y))
If Not s Is Nothing Then
s.BorderColor = Color.DarkRed
End If
End Sub