var featureLayer = (IFeatureLayer)layer; var legendInfo = (ILegendInfo)featureLayer; for (int li = 0; li < legendInfo.LegendGroupCount; li++) { var legendGroup = legendInfo.get_LegendGroup(li); for (int lg = 0; lg < legendGroup.ClassCount; lg++) { var legendClass = legendGroup.get_Class(lg); } }
To add to this, as a beginner I have a very basic doubt regarding symbology. I see that when I add any of my layers through "Add Layer" button, the layer is shown with default symbology and I hence feel the need to set the symbology through feature renderer every time i want to view the layer. But when I display the feature layers in California.GDB (which is given as sample data, that comes with ArcGIS Engine installation) by selecting from "Add Data" button, the layers come up with exactly the correct symbology as expected without the need to set any renderer explicitly. I want to know how this is achieved for California.gdb, where is the symbology information stored. This is a very big doubt that has been haunting, kindly excuse for using your post to add my question.
I also have similar issue regarding how to persist the symbology while export and import of layers. Request help.
Thanks and Regards,
Pavan
No problem - persisting / obtaining symbology 'data' has always seemed pretty hacky to me - in the past, I had done it in Python with symbology layers using:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000006n000000
and just saving layer symbology to apply this way ... I'd really like a nice example of how this works with ArcObjects, and whether I can just use the symbology properties rather than having to constantly re-save layers and store them somewhere.
Thanks for help, I have seen this link previously but did not know how create the "Symbology Layer". The Input Layer is the actual layer without symbology, I have a doubt on Symbology layer.. Is it a separate empty feature layer with same feature type as that of Input layer with just a field that matches one of the fields in the input layer used as criteria for symbology.. how is the difference between the colors assigned to various values in symbology layer .. renderer need to be created ?? . Once ApplySymbolgyFromLayer() is applied, the symbology is permanently applied like the case i mentioned for California.gdb when opened from Add Data button. Can you post a sample Symbology Layer and Input layer and apply it.. Request you to kindly reply with an example. plz
Regards,
Pavan