Deleting - How to pass parameters


I need some clarification regarding overriding EditDelete in GoView.
Here is my problem. I have two classes, one based on GoView called GraphView and another based on GoIconicNode called GraphNode. The Graphnode is assigned a SpecialID number. When deleting the Graphnode from the drawing area, I need to take that numberID and pass it to a database to make a corresponding deletion from a table. I can access the Graphnode from it’s file (i.e. use ‘this’) however, I need to override the GraphView.EditDelete() functionality to connect to a database and carry out the deletion. Trouble is, I can’t pass any parameters to EditDelete() and so can’t get it to know which GraphNode ID I am deleting.
Any tips?


The reason GoView.EditDelete can’t take a node as a parameter is that there may be many things in the selection that get deleted.
Furthermore, I believe that putting the database functionality into EditDelete isn’t the right thing to do, because there are other ways in which nodes (or other objects) might get “deleted” from a document.
I suggest that you implement a GoDocument.Changed event handler that notices the GoLayer.RemovedObject hint. The GoChangedEventArgs.Object property will hold the deleted object.
Alternatively, you can override GoDocument.FinishTransaction and run through the list of edits in the current transaction (GoDocument.UndoManager.CurrentEdit, which will be a GoUndoManagerCompoundEdit, whose .AllEdits property is a list of the GoChangedEventArgs that had been passed in earlier calls to the GoDocument.Changed event handlers).
The latter approach is preferable, to avoid having to do a lot of database transactions as objects are modified/inserted/deleted, since you can summarize/condense all the changes in a single database transaction.
There is a little bit of discussion of this in the User Guide under “Save and Load”.


Hi Walter,
Thanks for the response. I did try using GoDocument.Changed before and tested for the GoLayer.RemovedObject hint. It never gets called - somehow the deleting the GraphNode does not call this. (It does not work for the sample ProtoApp as well.)
I will try the latter approach and see how it goes.


Huh? The GoDocument.Changed event handler ought to work!
myDoc.Changed += new GoChangedEventHandler(this.myDoc_Changed);
private void myDoc_Changed(Object sender, GoChangedEventArgs evt) {
if (evt.Hint == GoLayer.RemovedObject) {
MessageBox.Show("removed: " + evt.Object.ToString());
And I just tried the sample ProtoApp.exe from the kit, and its GoDocument.Changed event handler in GraphNodeForm is being called, because deleting a node also removes the node from the properties window’s list of items in the combobox.


My mistake. I was overriding the functionality in the wrong place. Your code has helped.
It works perfect now. You’re a star.