ArcGIS Pro 2.7 API Reference Guide
CreateGroupElement(ILayoutElementContainer) Method
Example 

ArcGIS.Desktop.Layouts Namespace > IElementFactory Interface > CreateGroupElement Method : CreateGroupElement(ILayoutElementContainer) Method
Layout or GroupElement
Creates an empty group element at the root level of the element container. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
Overloads Function CreateGroupElement( _
   ByVal elementContainer As ILayoutElementContainer _
) As GroupElement

Parameters

elementContainer
Layout or GroupElement

Return Value

Returns a GroupElement.
Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
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 top most position.
Example
//Create an empty group element at the root level of the contents pane.


//Construct on the worker thread
await QueuedTask.Run(() =>
{
  GroupElement emptyGroupAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout);
  emptyGroupAtRoot.SetName("Empty group at root");
});
//Create an empty group element at the root level of another group element.

//Find an existing group element
GroupElement existingGroupAtRoot = layout.FindElement("Empty group at root") as GroupElement;

//Construct on the worker thread
await QueuedTask.Run(() =>
{
  GroupElement emptyGroupInGroupAtRoot = LayoutElementFactory.Instance.CreateGroupElement(existingGroupAtRoot);
  emptyGroupInGroupAtRoot.SetName("Empty group in group at root");
});
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

IElementFactory Interface
IElementFactory Members
Overload List