Drag'n'drop issues


I have to implement quite specific drag’n’drop behaviour:

  1. Drag’n’drop takes place between two GoView controls (two instances of the same subclass of GoView placed on the same form).
  2. Objects are moved from source view to destination view (not copied, only document to which they belong is changed).
  3. Drag operation between these two GoViews have to be tracked by undo/redo mechanism.

What’s the right solution for this?

I’ve tried to solve point 3) by setting the same UndoRedoManger to views (is this solution correct?):

GoUndoManager undoManager = new GoUndoManager();
view1.Document.UndoManager = undoManager;
view2.Document.UndoManager = undoManager;

But I’m not sure if this is ok.

Thanks in advance


Sure, you can share a GoUndoManager amongst multiple GoDocuments.
You need to override GoView.DoExternalDrop so that you can replace the standard copying behavior with the moving of objects from one document to another.
protected override IGoCollection DoExternalDrop(DragEventArgs evt) {
IDataObject data = evt.Data;
GoSelection sel = data.GetData(typeof(GoSelection)) as GoSelection;
if (sel != null) {
SizeF offset = GoTool.SubtractPoints(this.LastInput.DocPoint, sel.View.FirstInput.DocPoint);
foreach (GoObject obj in sel.CopyArray()) {
MoveSelection(this.Selection, offset, true);
FinishTransaction("moved between docs");
return this.Selection;
return base.DoExternalDrop(evt);
The only tricky point here is the cancellation of the drag in the source view.

Hi Walter,

It works! Thanks for great support :)