ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / IElementContainer Interface / FindElement Method
The element name.
(optional) When true the search continues in group elements. (default value = true)
Example

In This Topic
    FindElement Method (IElementContainer)
    In This Topic
    Finds the element specified by name.
    Syntax
    Function FindElement( _
       ByVal elementName As String, _
       Optional ByVal recurse As Boolean _
    ) As IElement

    Parameters

    elementName
    The element name.
    recurse
    (optional) When true the search continues in group elements. (default value = true)

    Return Value

    The element
    Example
    Create a group element with elements
    //Create a group with a list of elements at the root level of the contents pane.
    
    //Find an existing elements
    //container is IElementContainer - GroupLayer or Layout
    var elem1 = container.FindElement("Polygon 1");
    var elem2 = container.FindElement("Bezier Text");
    var elem3 = container.FindElement("Cloud Shape 2");
    
    //Construct a list and add the elements
    var elmList = new List<Element>
    {
      elem1,
      elem2,
      elem3
    };
    
    //Perform on the worker thread
    await QueuedTask.Run(() =>
    {
      //At 2.x - GroupElement groupWithListOfElementsAtRoot =
      //             LayoutElementFactory.Instance.CreateGroupElement(layout, elmList);
      //groupWithListOfElementsAtRoot.SetName("Group with list of elements at root");
      //
      GroupElement groupWithListOfElementsAtRoot =
              ElementFactory.Instance.CreateGroupElement(
                       container, elmList, "Group with list of elements at root");
    });
    
    // *** or ***
    
    //Create a group using a list of element names at the root level of the contents pane.
    
    //List of element names
    var elmNameList = new[] { "Para Text1", "Line 3" };
    
    //Perform on the worker thread
    await QueuedTask.Run(() =>
    {
      //At 2.x - GroupElement groupWithListOfElementNamesAtRoot =
      //   LayoutElementFactory.Instance.CreateGroupElement(layout, elmNameList);
      //         groupWithListOfElementNamesAtRoot.SetName(
      //                  "Group with list of element names at root");
    
      //At 3.x, use the names to find the relevant elements first
      //container is IElementContainer - GroupLayer or Layout
      var elems = container.FindElements(elmNameList);
      GroupElement groupWithListOfElementNamesAtRoot =
          ElementFactory.Instance.CreateGroupElement(
               container, elems, "Group with list of element names at root");
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also