1

I have a map with many feature classes on it. I want to use arcobjects to get to a selected layer (aka one of the feature classes) on the map, and change the fill color of all the polygons within that feature class. I don't want to add anymore features or make a new feature class, just change the colors of existing ones. I want to make this a user inputted color, so I want to use the color dialog in VS2013.

I've read that IGraphicsContainer is a useful interface to implement, but I don't know how to do that.

ILayerDescription layerdes = (ILayerDescription)featlayer;
layerdes.SelectionColor = colorDialog1.Color;

Implementing code with these lines gave me the error: Cannot implicitly convert type 'System.Drawing.Color' to 'ESRI.ArcGIS.Display.IColor'

1

Convert the .NET color object from the color dialog to an IColor first using the RGB components first. Passing the color properties to a method like this should do it:

public IColor GetColor(int pRed, int pGreen, int pBlue)
    {
        IRgbColor rgb = new RgbColorClass();
        rgb.Red = pRed;
        rgb.Green = pGreen;
        rgb.Blue = pBlue;
        return (IColor)rgb;
    }
|improve this answer|||||
0

```CS

    IFeatureClass featureClass = null;
    IObjectClass objectClass = feature.Class;
    featureClass = objectClass as IFeatureClass; 

    IGeoFeatureLayer layer = featureLayer as IGeoFeatureLayer;
    IFeatureRenderer featureRenderer = layer.Renderer;
    ISymbol symbol = null;


    if (featureRenderer is IUniqueValueRenderer)
    {
        IUniqueValueRenderer uniqueValueRenderer = featureRenderer as IUniqueValueRenderer;
        symbol = uniqueValueRenderer.DefaultSymbol;
    }
    if (featureRenderer is ISimpleRenderer)
    {
        ISimpleRenderer simpleRender = featureRenderer as ISimpleRenderer;
        symbol = simpleRender.Symbol;
    } ```
|improve this answer|||||

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.