Rectangle dangling after deleted by the view

HI

I have a GoNode object removed out of a subgraph, and delete that node using base.DeleteSelection and call the refresh after that. The view/document does delete the object, but the view keeps a green rectangle on the last position of the node in the view. Can someone shed some light on how to make that green rectangle ?

Thanks

Is it the selection highlight?

Nope. It is not highlighted.

can you put up before & after screenshots? thanks.

Begining…
Begining
some menu operation to remove a GoNode out of the subgraph

End : undesired rectangle left

Thanks


for some reason the final picture failed to be loaded into the forum. The address show in previews is :

UserUploads/temp/20080208_154335_DangleRectangle.JPG

What version of GoDiagram are you using, and how does the context menu command remove the node from the subgraph?

2.6.2.2. The command will

  1. move the GoNode out of SubGraph by calling document.start transaction twice, call SubGraph.remove
  2. Call Document.Add to add the node that move out of subgraph
  3. position that node into somewhere
  4. call Document.finishTransaction twice
  5. Make a GoSelection and add the node into the selection.
  6. call GoView.DeleeteSelection to delete the selection.

I probably made some mistakes that I don’t know or not following the best practice.

Why do you call StartTransaction/FinishTransaction twice each? Once each should be sufficient.

You shouldn’t be constructing a GoSelection. But if you do, you probably shouldn’t be passing the GoView as the GoSelection constructor argument – you should use null instead. However, the main point, that you probably shouldn’t be constructing a GoSelection at all, is important.

I can understand your wanting to “reparent” the selected nodes to be part of the document instead of being part of the subgraph. However, I don’t understand why you then delete them.

I think your command should just be defined as:

[code] public override GoContextMenu GetContextMenu(GoView view) {
GoContextMenu cm = new GoContextMenu(view);
if (view.CanEditDelete())
cm.MenuItems.Add(new MenuItem(“Delete”, new EventHandler(this.DeleteMenuItem_Click)));
. . .
}

private void DeleteMenuItem_Click (object sender, System.EventArgs e) {
  GoView v = GoContextMenu.FindView(sender as MenuItem);
  if (v != null)
    v.EditDelete();
}[/code]

This code is taken from the LimitedNode example class in Demo1. There are other examples of this, too, I believe.

This is all code you could add to your GoSubGraph-derived class. If you don’t want to define a node class, you can put similar code in a view event handler.

Hi
Pass a null to the GoSelection actually solves the problem.

Thanks