I have a layer file that has a few polygons in it, each of these polygons is required to be a different color based a column in the DBF file.

I normally color layers like this:

ISimpleRenderer simplerenderer = geolayer.Renderer as ISimpleRenderer;
SimpleFillSymbol simpleFillSymbol = simplerenderer.Symbol as SimpleFillSymbol;
simpleFillSymbol.Color = selectedColor;

But this doesn't have a mechanism to use multiple colors on the same layer. How does one accomplish this?

ArcEngine 10, C#, VS2010


A simple renderer (ISimpleRenderer) will not do, you need to use an unique values renderer, which will work perfectly if you need to base your symbology on one column.

It is implemented by the UniqueValueRenderer class, most of the work can be done via IUniqueValueRenderer interface. You basically map a column value (or a set of values) to a symbol.

There is also a sample on how to set up a unique value renderer which could be of some help to you.


Just to add on to petr k.'s answer, ArcGIS Engine has the capability to load an MXD into the MapControl and it can load layer files.

If you are loading the same DBF file each time you run the application, you can create an MXD using ArcMap to setup your symbology and then load the MXD into ArcGIS Engine at runtime.

Alternatively, you can configure layer symbology in ArcMap and then right click on it, hit Save to Layer. You can then load this layer into your MapControl using IMap::AddLayer or by opening it as an ILayerFile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.