I have a polyline feature layer. After doing some computation, I update a field of that layer and want to set unique color for different value of that field. We can do this from symbology using unique values. But I want to do it programmatically.
I know there should be a very easy way to do this thing with arcObjects. But I couldn't find the way.
I go through How to define a renderer for your layer document. But I did not find the way to set "Value Field" and "Add All Values" options here. And of course I have tried to use IUniqueValueRenderer.AddReferenceValue Method. But the document is not giving me all necessary information.
Question : How to set unique color value for different value of a specific field using c#? It will be vary helpful if anyone can give me some pointer about this.
Thanks.
Best Answer
First, to set UniqueValueRenderer in programmably, "Value Field" is set as,
Next, RandomColorRamp does not guarantee unique colors. So you need to implement color creation part by your own self. One approach, create existed color list and check if the color is already used. I wrote the sample code referenced from How to define a renderer for your layer . And also specialized to SimpleLineSymbol. But you must consider about maximum number of values. Theoretically, you can use only up to 65535 colors.