Changing Names in TOC Doesn't Update Legend Properly

http://gis.stackexchange.com/questions/10969/changing-names-in-toc-doesnt-update-legend-properly

This is related to an ArcMap add-in I coded up this past week.

I'm trying to rename a layer in ArcMap and have the legend refresh properly. The renaming part is working fine, however I cannot get the legend in the layout to update properly.

I call CurrentContents.Refresh() to refresh the name in the table of contents, which works.

If I search through the map surrounds and call .Refresh() on the legend, then do an ActiveView.PartialRefresh() on it, the legend gets all out of whack. This is why I am trying to simply trigger the same event as when the user manually changes the name of a layer.

The API documentation seems to say that MxDocument.UpdateContents() will trigger the events needed to refresh the legend. However, this does not seem to be the case. In addition to the above methods I have tried ActiveView.ContentsChanged() to no avail.

Edit: I am writing this in C# but can read VB if you feel more comfortable writing in that.

Any suggestions are welcome.

Thanks,

Mat

原文地址:https://www.cnblogs.com/adodo1/p/4327438.html