Select to view content in your preferred language

Notifying ArcMap document to save persistent data for Add-in

679
2
11-16-2010 01:17 PM
JeffreyHamblin
Occasional Contributor
I'm working on an Add-in (using C#) that needs to store some information in the MXD. I got that working successfully using the concepts outlined in the "Persisting data by implementing an extension using add-ins" topic in the SDK Help. However, unless the user saves the document, the changes aren't written (of course). Looking for a way to notify ArcMap that the document needs to be saved, the only thing I could find that works is calling:

ArcMap.Document.UpdateContents();

once for each document session if the data I am storing changes. If I do that, then ArcMap will prompt the user to save if necessary when closing the document -- which is exactly what I want.

Is this the correct method to use?

This was kind of a guess, since I could not find any other posts or samples about this subject. The documentation for the UpdateContents() method only states:
"Notifies the document that the contents have been updated."
"Refreshes the current view in the table of contents. UpdateContents is a shortcut - it calls Refresh on the current contents view (IContentsView::Refresh)."

It was enough to give it a try, but it would be nice if the documentation was more explicit about it producing a "save" prompt.

-Jeff
0 Kudos
2 Replies
NeilClemmons
Honored Contributor
You need to set the document save flag by calling IDocumentDirty2.SetDirty.
0 Kudos
JeffreyHamblin
Occasional Contributor
Thank you for the information, Neil. That's exactly what I wanted.

I searched the ArcObjects SDK in the Resource Center for every term I could think of, and did not find that. I should have tried "dirty".

-Jeff
0 Kudos