ArcGIS Pro 2.6 API Reference Guide
GroupElement Class
Members  Example 

ArcGIS.Desktop.Layouts Namespace : GroupElement Class
Represents a group element that appears in the layout contents pane.
Object Model
GroupElement ClassElement ClassCoordinate2D StructureEnvelope ClassCIMElement ClassIElementParent Interface
Syntax
Remarks

It is possible that group elements can be nested in another group element. If the element container is a Layout then the element gets added to the root level of the layout TOC at the top most position. If the element container is a GroupElement then it gets added to the group at the topmost position.

The FindElement method will also find elements nested in a group element.

If you want to work with all the elements within a group element, use the Elements property to return the collection of elements in a group element.

Example
//Create an empty group element at the root level of the contents pane

//Create on worker thread
await QueuedTask.Run(() =>
{
  GroupElement grp1 = LayoutElementFactory.Instance.CreateGroupElement(layout);
  grp1.SetName("Group");
});

// *** or ***

//Create a group element inside another group element

//Find an existing group element
GroupElement existingGroup = layout.FindElement("Group") as GroupElement;
      
//Create on worker thread
await QueuedTask.Run(() =>
{
  GroupElement grp2 = LayoutElementFactory.Instance.CreateGroupElement(existingGroup);
  grp2.SetName("Group in Group");
});
//Create a group with a list of elements at the root level of the contents pane.

//Find an existing elements
Element scaleBar = layout.FindElement("Scale Bar") as Element;
Element northArrow = layout.FindElement("North Arrow") as Element;
Element legend = layout.FindElement("Legend") as Element;

//Construct a list and add the elements
List<Element> elmList = new List<Element>
{
  scaleBar,
  northArrow,
  legend
};

//Perform on the worker thread
await QueuedTask.Run(() =>
{
  GroupElement groupWithListOfElementsAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, elmList);
  groupWithListOfElementsAtRoot.SetName("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[] { "Table Frame", "Chart Frame" };

//Perform on the worker thread
await QueuedTask.Run(() =>
{
  GroupElement groupWithListOfElementNamesAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, elmNameList);
  groupWithListOfElementNamesAtRoot.SetName("Group with list of element names at root");
});
Inheritance Hierarchy

System.Object
   ArcGIS.Desktop.Framework.Contracts.PropertyChangedBase
      ArcGIS.Desktop.Layouts.Element
         ArcGIS.Desktop.Layouts.GroupElement

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 7

See Also

Reference

GroupElement Members
ArcGIS.Desktop.Layouts Namespace