ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / Layout Class / UnGroupElement Method
The group element whose elements will be ungrouped
Example

In This Topic
    UnGroupElement Method (Layout)
    In This Topic
    Ungroup the elements contained in 'group'. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void UnGroupElement( 
       GroupElement group
    )
    Public Sub UnGroupElement( _
       ByVal group As GroupElement _
    ) 

    Parameters

    group
    The group element whose elements will be ungrouped
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Value cannot be null: group
    elements must belong to layout 'URI'
    Example
    Un-Group Graphic Elements
    var selectedElements = layout.GetSelectedElements().ToList(); 
    if (selectedElements?.Any() == false)//must be at least 1.
      return;
    var elementsToUnGroup = new List<GroupElement>();
    //All selected elements should be grouped elements.
    if (selectedElements.Count() == selectedElements.OfType<GroupElement>().Count())
    {
      //Convert to a GroupElement list.
      elementsToUnGroup = selectedElements.ConvertAll(x => (GroupElement)x);
    }
    if (elementsToUnGroup.Count() == 0)
      return;
    //UnGroup many grouped elements
    layout.UnGroupElements(elementsToUnGroup);
    //Ungroup one grouped element
    layout.UnGroupElement(elementsToUnGroup.FirstOrDefault());
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also