Denying Drag Enter in GoView

How can I deny the drag enter event in a GoView Control, so that the cursor icon also changes.

protected override void OnDragEnter(DragEventArgs evt)
{
if (evt.AllowedEffect == DragDropEffects.Move)
{
base.OnDragEnter(evt);
}
else
{
//Deny action, but cursor doesn’t change like in WinControls
}
}

That probably depends on where the drag started. It also probably depends on where you care to disallow the drag, if it depends on particular objects in your view.

If the user is dragging some GoObjects from another GoView, including from a GoPalette, you might find it easiest to use the GoView.ObjectSelectionDropReject event and/or the BackgroundSelectionDropReject event, along with setting GoView.DragsRealtime to true and GoView.ExternalDragDropsOnEnter to true.

Then you can examine the GoView.Selection to decide what kind of objects are being dragged, and (for the GoView.ObjectSelectionDropReject event) you can consider the object that the mouse is over. (There’s no document object that the mouse is over in the BackgroundSelectionDropReject event.)

Another advantange of this technique is that if you have a lot of cases to consider, you can override GoObject.OnSelectionDropReject for your particular object classes, so that that event-handling code can be spread out to the node and/or link classes that you are using, instead of centralizing and complicating the drag-and-drop code in your Form.

This technique also handles internal drag-and-drops (i.e. within the view).

If the drag is coming from some other kind of Control (i.e., not GoObjects from a GoView) then you can override the GoView.DoExternalDrag, DoExternalDrop, and GetExternalDragImage methods.

The first technique is demonstrated by the Planogrammer sample; the second is demonstrated by the Flowgrammer sample. Actually, there are probably some other examples of this – search for “SelectionDrop” or “ExternalDr”.