ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / BasicFeatureLayer Class / SetCustomSelectionColor Method / SetCustomSelectionColor(CIMColor) Method
The color to display the layers selection.
Example

In This Topic
    SetCustomSelectionColor(CIMColor) Method
    In This Topic
    Sets the layer to display its selection in the specified color. Use null to specify that the layer should display its selection in the default selection color defined in ArcGIS.Desktop.Core.SelectionOptions.SelectionColor. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void SetCustomSelectionColor( 
       CIMColor color
    )
    Public Overloads Sub SetCustomSelectionColor( _
       ByVal color As CIMColor _
    ) 

    Parameters

    color
    The color to display the layers selection.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    This method is ignored if the layer does not support custom selection. See SupportsCustomSelectionProperties .

    To assign a color for polygon interiors use SetCustomSelectionColor(CIMColor,CIMColor)./>

    Example
    Change the layer selection color - using Layer methods
    {
      await QueuedTask.Run(() =>
      {
        if (featureLayer.SupportsCustomSelectionProperties())
        {
        // get the set of properties
        var (useCustomSelectioncolur, customSelectionColor, usecustomSelectioinFilleColor, customSelectionFillColor) = featureLayer.GetCustomSelectionProperties();
    
        // set the layer to use a specific color
        featureLayer.SetCustomSelectionColor(ColorFactory.Instance.RedRGB);
    
        // or set a specific color AND fill color
        featureLayer.SetCustomSelectionColor(ColorFactory.Instance.RedRGB, ColorFactory.Instance.BlueRGB);
    
        // reset to use the default selection color
          featureLayer.SetUseDefaultSelectionColor();
        }
    
        if (!featureLayer.IsVisible)
        {
          featureLayer.SetVisibility(true);
        }
        //Do a selection
        mapView.SelectFeatures(mapView.Extent);
      });
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.8 or higher.
    See Also