Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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


2 Answers 2

up vote 5 down vote accepted

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.


This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .