English

How To: Remove a data frame from a map document using ArcObjects

Summary

Instructions provided describe some sample code to remove a data frame from the page layout by calling the IGraphicsContainer::DeleteElement() method.

Procedure

  • [VB.NET]

    Code:
    Dim pMap As IMap = pMapDoc.Map(0)
    Dim pContainer As IGraphicsContainer = pMapDoc.PageLayout
    Dim pMapframe As IMapFrame = pContainer.FindFrame(pMap)
    pContainer.DeleteElement(pMapframe)

  • [C#]

    Code:
    IMap pMap = pMapDoc.get_Map(0);
    IGraphicsContainer pContainer = (IGraphicsContainer)pMapDoc.PageLayout;
    IMapFrame pMapframe = (IMapFrame)pContainer.FindFrame(pMap);
    pContainer.DeleteElement((IElement)pMapframe);

  • [JAVA]

    Code:
    IMap pMap = pMapDoc.getMap(0);
    IGraphicsContainer pContainer = (IGraphicsContainer)pMapDoc.getPageLayout();
    IMapFrame pMapframe = (IMapFrame)pContainer.findFrame(pMap);
    pContainer.deleteElement((IElement)pMapframe);

Related Information