Import Legend Style from Existing Layer to New One

1861
2
11-30-2012 11:46 AM
RobertDouglas2
New Contributor
Hi,

I have an AddIn that creates multiple layers of selected features and then turns off the original layers. I would like to take the Legend Style of the original layer and apply it to the new layers when they are added to the legend automatically. The AddIn was built with C# but I could stumble though VB if anyone has examples/ideas in either. Thanks in advance.

Robbie
0 Kudos
2 Replies
NeilClemmons
Regular Contributor III
If you mean that you would like to copy the symbology from one layer to another then you can use the IObjectCopy interface to copy the layer's renderer.  You get and set a layer's renderer via IGeoFeatureLayer.Renderer.  You could simply set the renderer of one layer to the renderer of another layer but that would result in both layers using the same renderer object in memory.  So, you should deep clone the renderer using IObjectCopy and set the second layer's renderer using the clone.
0 Kudos
RobertDouglas2
New Contributor
Hi Neil,

Thanks for the reply.

I got the symbology of the layer with the renderer already. What I need imported from the existing layer to the new one is the formatting style of the way the patch and text (size, font, placement, orientation, etc.) looks in the legend that is inserted in Layout View not just the symbology in the TOC and the legend's patch color. I want to programatically set these properties to be the same as another layer's when my new layer is added; the same way they can be set manually in Legend Properties > "Style..." > Legend Item Selector.

[ATTACH=CONFIG]19662[/ATTACH] [ATTACH=CONFIG]19663[/ATTACH]

Sorry I wasn't more specific in my initial post.

Thanks for the support,
Robbie
0 Kudos