I have created an ArcMap add-in for browsing data layers and adding them to the TOC. I would like to add a button that when clicked will open the selected layers item description (before it is added to the TOC) however I can't seem to find any documentation on how to accomplish this.

Basically I want the same functionality as the 'View Item Description...' in the 'Data' menu when right clicking a layer in the TOC. So when the button is pressed the item description window is opened. Any one have any ideas I thought for sure there would be an easy way to do this?


1 Answer 1


Below is some VBA code that shows you how to open the Item Description window from the first layer in the TOC.

Public Sub OpenItemDescription()
    ' Get Application
    Dim pApp As IApplication
    Set pApp = Application

    ' Get Map document
    Dim pMXD As IMxDocument
    Set pMXD = ThisDocument

    ' Get Map
    Dim pmap As IMap
    Set pmap = pMXD.FocusMap

    ' Get first layer in TOC
    Dim pLayer As ILayer
    Set pLayer = pmap.Layer(0)

    ' Get Dataset
    Dim pDataset As IDataset
    Set pDataset = pLayer
    Dim pName As IName
    Set pName = pDataset.FullName
    Dim pFeatureClassName As IFeatureClassName
    Set pFeatureClassName = pName

    ' Get Metadata for dataset
    Dim pMetaData As IMetadata
    Set pMetaData = pFeatureClassName

    ' Open window
    Dim pMetadataViewWindow  As IMetadataViewWindow2
    Set pMetadataViewWindow = New MetadataViewWindow
    With pMetadataViewWindow
        Set .Application = pApp
        Set .Layer = pLayer
        Set .Metadata = pMetaData.Metadata
        .Show True
    End With
End Sub


Here is the code in c#.

 private void viewMetadataButton_Click(object sender, EventArgs e)
            IGxLayer gxLayer = new GxLayerClass();
            IGxFile gxFile = gxLayer as IGxFile;
            gxFile.Path = @lyrPath;
            ILayer layer = gxLayer.Layer as ILayer;
            IDataset pDataSet = (IDataset)layer;
            IName pName = (IName)pDataSet.FullName;
            IFeatureClassName pFeatureClassName = (IFeatureClassName)pName;
            IMetadata pMetadata = (IMetadata)pFeatureClassName;
            IMetadataViewWindow2 pMetadataViewWindow = (IMetadataViewWindow2) new MetadataViewWindow();
            pMetadataViewWindow.Application = ArcMap.Application;
            pMetadataViewWindow.Layer = layer;
            pMetadataViewWindow.Metadata_2 = pMetadata.Metadata;
  • Thanks for this it looks like the IMetadataViewWindow classes are what I am looking for. I'll test it and update. Jun 17, 2016 at 12:32
  • I basically used the code from 'Get Dataset' down and it worked great thanks. Aside from my code being in c# the only difference was that since my layer isn't yet in the TOC so I define ILayer differently. Jun 17, 2016 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.