Board index » delphi » Deleting TTreeNode in OnEditing event causes Exception

Deleting TTreeNode in OnEditing event causes Exception

As the subject says:

Deleting TTreeNode in OnEditing event causes an Access violation

i want to delete the entire Node if the User empties the Text of the
Node.

It happens, but where does the exception come from, and how to solve
it.?

--
when replying directly , remove
NOSPAMPLEASE
from my adress

Greetings,
Frans.

 

Re:Deleting TTreeNode in OnEditing event causes Exception


Dear Frans,

When the event OnEditing or OnEdited is called, the node is not passed
as var... if you delete the node and you try to set Node to NIL, you
will see that it fails because you don't set the real treenode to nil,
but the 'copy' of the treenode.
I did not find a solution yet..

Arnim

Frans Trentelman schreef:

Quote
> As the subject says:

> Deleting TTreeNode in OnEditing event causes an Access violation

> i want to delete the entire Node if the User empties the Text of the
> Node.

> It happens, but where does the exception come from, and how to solve
> it.?

> --
> when replying directly , remove
> NOSPAMPLEASE
> from my adress

> Greetings,
> Frans.

Re:Deleting TTreeNode in OnEditing event causes Exception


I don't think you can delete a node in an event that is working with the
node... The node disappears while still being worked on, so an access
violation is inevitable. Try posting a message in the OnEdit event to
cause the node to be deleted AFTER the OnEdit finishes.

David

Quote
Frans Trentelman wrote:
> As the subject says:

> Deleting TTreeNode in OnEditing event causes an Access violation

> i want to delete the entire Node if the User empties the Text of the
> Node.

> It happens, but where does the exception come from, and how to solve
> it.?

> --
> when replying directly , remove
> NOSPAMPLEASE
> from my adress

> Greetings,
> Frans.

Other Threads