Drap Drop funtionality is a little different between VB6 and Windows Forms.
Specially the event handlers.
The following helpers facilitates the migration of such events.
Suppose we have a VB Form like the following:
The signature in Drag_XXX events in .NET does not include the source argument. A click fix can be applied with the following extensions methods.
The VB6 Text1.Drag vbBeginDrag
line is changed to Text1.BeginDrag();
And the XXX_DragOver
events must include the following lines:
e.Effect = DragDropEffects.All;
var source = e.GetSource();
The e.Effect
must be set to allow changing the cursor. And the e.GetSource()
extension method call gets the source object, so the rest of the handler logic remains the same.
One final detail is that we must set the forms AllowDrop
property to true as well as the target object. In this case Label1.AllowDrop = true
The resulting code will be something like:
NOTE: Custom Cursors is a tricky business and we might cover that on another post.