ArcGIS Pro 2.9 API Reference Guide
CreateGroupElement(ILayoutElementContainer,IList<Element>) Method
Example 

ArcGIS.Desktop.Layouts Namespace > LayoutElementFactory Class > CreateGroupElement Method : CreateGroupElement(ILayoutElementContainer,IList<Element>) Method
Layout or GroupElement
A list of layout elements.
Creates a group element from a list of elements. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
Public Overloads Function CreateGroupElement( _
   ByVal elementContainer As ILayoutElementContainer, _
   Optional ByVal elements As IList(Of Element) _
) As GroupElement

Parameters

elementContainer
Layout or GroupElement
elements
A list of layout elements.

Return Value

Returns a GroupElement.
Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
Map has reached maximum graphics count limit of 4000 elements. One or more elements cannot be created.
Map has reached maximum graphics size limit of 10 MB. One or more elements cannot be created.
Remarks
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.
Example
//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;

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

//Construct on the worker thread
await QueuedTask.Run(() =>
{
  GroupElement groupWithListOfElementsAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, elmList);
  groupWithListOfElementsAtRoot.SetName("Group with list of elements at root");
});
Requirements

Target Platforms: Windows 11, Windows 10, Windows 8.1

See Also

Reference

LayoutElementFactory Class
LayoutElementFactory Members
Overload List