How to know whether an IElement object is moved or deleted on the map? or prevent it?

680
2
Jump to solution
01-30-2014 01:59 PM
SuiHuang
Occasional Contributor II
Hi Everybody:

    I am writing an ArcMap 10.0 extension that provides a multiple step workflow. In one of the steps of the workflow, my code will generate a graphical element (IElement object) on the map display to give some information to user to continue next step, and my code is cleaning it up at the end (currently deleting all graphical elements on the map).

    However, in the design above the extension will prevent user from using graphical or text element by using the out-of-box "Draw" toolbar, because my extension will clean the elements up from time to time.

    I want to improve this but keeping the reference to the IElement object when it is created, and delete only it at the end instead of deleting all elements. However, the geraphical element can be deleted by tools in "Draw" toolbar. If it is accidentially deleted, my deletion code will throw exception at the end. Is there anyway for my code to detect whether that element is no longer existing?

    Alternatively, if I have a way to prevent user to delete or edit that element, it should also work, any method?

    Thank you!
0 Kudos
1 Solution

Accepted Solutions
NeilClemmons
Regular Contributor III
Use IElementProperties to assign a name to the element when it is created.  When you go to delete the element, loop through the graphics container looking for an element with that name.  If you don't find it, it has already been deleted.

View solution in original post

0 Kudos
2 Replies
NeilClemmons
Regular Contributor III
Use IElementProperties to assign a name to the element when it is created.  When you go to delete the element, loop through the graphics container looking for an element with that name.  If you don't find it, it has already been deleted.
0 Kudos
SuiHuang
Occasional Contributor II
It works, thank you!
Use IElementProperties to assign a name to the element when it is created.  When you go to delete the element, loop through the graphics container looking for an element with that name.  If you don't find it, it has already been deleted.
0 Kudos