ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Editing Namespace / AnnotationProperties Class / TextGraphic Property
Example

In This Topic
    TextGraphic Property
    In This Topic
    Gets the ArcGIS.Core.CIM.CIMTextGraphic representation of the annotation.
    Syntax
    Public ReadOnly Property TextGraphic As CIMTextGraphic
    public CIMTextGraphic TextGraphic {get;}
    Example
    Modify Annotation Text Graphic
    // Modifies the text graphic of a selected annotation feature in the specified annotation layer.
    await QueuedTask.Run(() =>
    {
      var selection = annotationLayer.GetSelection();
      if (selection.GetCount() == 0)
        return;
      // use the first selected feature 
      var insp = new Inspector();
      insp.Load(annotationLayer, selection.GetObjectIDs().FirstOrDefault());
      // getAnnoProperties should return null if not an annotation feature
      AnnotationProperties annoProperties = insp.GetAnnotationProperties();
      // get the textGraphic
      CIMTextGraphic textGraphic = annoProperties.TextGraphic;
      // change text
      textGraphic.Text = "Hello world";
      // set x,y offset via the symbol
      var symbol = textGraphic.Symbol.Symbol;
      var textSymbol = symbol as CIMTextSymbol;
      textSymbol.OffsetX = 2;
      textSymbol.OffsetY = 3;
      textSymbol.HorizontalAlignment = HorizontalAlignment.Center;
      // load the updated textGraphic
      annoProperties.LoadFromTextGraphic(textGraphic);
      // assign the annotation properties back 
      insp.SetAnnotationProperties(annoProperties);
      EditOperation op = new EditOperation
      {
        Name = "modify symbol"
      };
      op.Modify(insp);
      if (!op.IsEmpty)
      {
        bool result = op.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not
      }
    });
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also