ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / Element Class / SetAnchor Method
Anchor
Example

In This Topic
    SetAnchor Method (Element)
    In This Topic
    Sets the anchor position of the element. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Sub SetAnchor( _
       ByVal anchor As Anchor _
    ) 
    public void SetAnchor( 
       Anchor anchor
    )

    Parameters

    anchor
    Anchor
    Exceptions
    ExceptionDescription
    This method must be called within the lambda passed to QueuedTask.Run.
    This element requires its mapview to be active
    Remarks
    Placement for an element contained in graphics layer requires the mapview be active.
    Example
    Update text element properties
    {
      //Update text element properties for an existing text element.
      //Note: Must be on QueuedTask.Run
      // Reference and load the layout associated with the layout item
      if (layout != null)
      {
        // Reference a text element by name
        TextElement txtElm = layout.FindElement("MyTextElement") as TextElement;
        if (txtElm != null)
        {
          double x = 2.0;
          double y = 3.0;
          // Change placement properties
          txtElm.SetAnchor(Anchor.CenterPoint);
          txtElm.SetX(x);
          txtElm.SetY(y);
    
          // Change TextProperties
          TextProperties txtProperties = new TextProperties(
                            "Hello world", "Times New Roman", 48, "Regular");
          txtElm.SetTextProperties(txtProperties);
        }
      }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also