handling drag & drop

I'm trying to handle a drop event in a shape but dont see how to do this. I would like to be able to drop something on the shape and then take some actions. Any ideas?

Thanks

[178 byte] By [BennyV] at [2008-1-10]
# 1

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

JohnHart_MSFT at 2007-10-3 > top of Msdn Tech,Visual Basic,Visual Basic Power Packs...