ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / FeatureLayer Class / RecalculateRenderer Method / RecalculateRenderer(FeatureRendererTarget,Boolean,Boolean) Method
A FeatureRendererTarget indicating the intended usage of the resulting renderer. Valid arguments for this method are FeatureRendererTarget.Default and FeatureRendererTarget.PreviousObservations.
Indicates whether all the unique values should be generated. Setting this flag to false will generate only the first hundred unique values, if the dataset has that many.
Indicates whether to preserve the existing symbology or not (optional). Default value is true.

In This Topic
    RecalculateRenderer(FeatureRendererTarget,Boolean,Boolean) Method
    In This Topic
    Updates the renderer based on updated values from the data source. For example, if a new unique value gets added to the FeatureClass, in case of unique value renderer, it gets updated with the newly added value. Similarly with class breaks renderer, it tries best to preserve the number of class breaks and recalculates the break values based on the updated values. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Overloads Sub RecalculateRenderer( _
       ByVal featureRendererTarget As FeatureRendererTarget, _
       ByVal generateAllUniqueValues As Boolean, _
       Optional ByVal preserveSymbols As Boolean _
    ) 

    Parameters

    featureRendererTarget
    A FeatureRendererTarget indicating the intended usage of the resulting renderer. Valid arguments for this method are FeatureRendererTarget.Default and FeatureRendererTarget.PreviousObservations.
    generateAllUniqueValues
    Indicates whether all the unique values should be generated. Setting this flag to false will generate only the first hundred unique values, if the dataset has that many.
    preserveSymbols
    Indicates whether to preserve the existing symbology or not (optional). Default value is true.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    This method was called with an unsupported FeatureRendererTarget value.
    Error HRESULT {0} has been returned from a call to a COM component
    Remarks
    Intended for use with StreamLayer. For non-stream layer types use FeatureRendererTarget.Default. Passing FeatureRendererTarget.PreviousObservations or FeatureRendererTarget.TrackLines for a non-track aware layer (feature or stream) will throw a System.InvalidOperationException.
    If a new unique value is added to the underlying FeatureClass, in case of a unique value renderer, it gets updated with the newly added value. Similarly with class breaks renderer, RecalculateRenderer tries best to preserve the number of class breaks and recalculates the break values based on the updated values.
    Calling RecalculateRenderer on a layer with a unique value renderer or class breaks renderer that has a null color ramp (check the renderer's ColorRamp property via the CIM) will throw a System.Runtime.InteropServices.COMException.
    Note: Set generateAllUniqueValues = false to restrict the number of regenerated values to be limited to the first 100. This is a useful optimization for those cases where a renderer may contain 100s or 1000s of unique values that would otherwise be regenerated.
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also