ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / FeatureLayer Class / SetLabelVisibility Method
true make labels to draw.
Example

In This Topic
    SetLabelVisibility Method (FeatureLayer)
    In This Topic
    Toggles the feature layer's label's visibility. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Sub SetLabelVisibility( _
       ByVal isLabelVisible As Boolean _
    ) 
    public void SetLabelVisibility( 
       bool isLabelVisible
    )

    Parameters

    isLabelVisible
    true make labels to draw.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Enable labeling on a layer
    {
        //Note: needs to be called on the MCT
        // toggle the label visibility
        featureLayer.SetLabelVisibility(!featureLayer.IsLabelVisible);
    }
    How to apply a Text Symbol to label of a layer
    {
      var cimMap = MapView.Active.Map.GetDefinition();
    
      CIMTextSymbol simpleTextSymbol = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.GreenRGB, 8.5, "Corbel", "Regular");
      var lyrDefn = theLayerToLabel.GetDefinition() as CIMFeatureLayer;
      //Get the label classes - we need the first one
      var listLabelClasses = lyrDefn.LabelClasses.ToList();
      var theLabelClass = listLabelClasses.FirstOrDefault();
      //Place all labels horizontally
      theLabelClass.StandardLabelPlacementProperties.LineLabelPosition.Horizontal = true;
      //theLabelClass.MaplexLabelPlacementProperties.AlignLabelToLineDirection = true;
      //Set the label classes' symbol to the custom text symbol
      theLabelClass.TextSymbol.Symbol = simpleTextSymbol;
      lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back
      theLayerToLabel.SetDefinition(lyrDefn);
      (theLayerToLabel as FeatureLayer).SetLabelVisibility(true);
    }
    Enable labeling of a layer
    /// <summary>
    {
      // Note: call within QueuedTask.Run()
      {
        if (!featureLayer.IsLabelVisible)
          //set the label's visibility
          featureLayer.SetLabelVisibility(true);
      }
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also