ArcGIS Pro 2.7 API Reference Guide
CreateGroupElement(ILayoutElementContainer,String[]) Method
Example 

ArcGIS.Desktop.Layouts Namespace > IElementFactory Interface > CreateGroupElement Method : CreateGroupElement(ILayoutElementContainer,String[]) Method
Layout or GroupElement
A string array that represents a list of element names.
Creates a group element at the root level of the TOC. This method must be called on the MCT. Use QueuedTask.Run.
Syntax

Parameters

elementContainer
Layout or GroupElement
elementNames
A string array that represents a list of element names.

Return Value

Returns a GroupElement.
Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
Remarks
When the element container is a Layout then the element gets added to the root level of the layout TOC at the top most position.
Example
//Create a group using a list of element names at the root level of the contents pane.

//Build list of element names
var elmNameList = new[] { "Table Frame", "Chart Frame" };

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

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

IElementFactory Interface
IElementFactory Members
Overload List