I am totally new to arcobjects. I want to get the feature class names withın a dataset and add them to a listbox. I was able to get the dataset names but i do not know how to iterate through the feature class names within these datasets.

Public Sub GetWorkspace()

    Dim pEnumGxObj As ESRI.ArcGIS.Catalog.IEnumGxObject
    Dim pFCFilter As New ESRI.ArcGIS.Catalog.GxFilterWorkspaces
    Dim pGxDatabase As ESRI.ArcGIS.Catalog.IGxDatabase2
    Dim pGxDialog As New ESRI.ArcGIS.CatalogUI.GxDialog
    Dim pGxObject As ESRI.ArcGIS.Catalog.IGxObject
    Dim pWorkspace As ESRI.ArcGIS.Geodatabase.IWorkspace

    pGxDialog.ObjectFilter = pFCFilter

    If Not pGxDialog.DoModalOpen(My.ArcMap.Application.hWnd, pEnumGxObj) Then Exit Sub

    pGxObject = pEnumGxObj.Next

    If pGxObject Is Nothing Then Exit Sub
        If TypeOf pGxObject Is ESRI.ArcGIS.Catalog.IGxDatabase2 Then
            pGxDatabase = pGxObject
            pWorkspace = pGxDatabase.Workspace
            System.Windows.Forms.MessageBox.Show("This is likely a shapefile workspace")
        End If

        Dim pEnumDSName = pWorkspace.DatasetNames(esriDatasetType.esriDTAny)

        Dim pSdeDSName = pEnumDSName.Next
        While Not pSdeDSName Is Nothing
            pSdeDSName = pEnumDSName.Next
        End While

    Catch ex As Exception
        System.Windows.Forms.MessageBox.Show(ex.ToString, "GetWorkspace")

    End Try
End Sub

1 Answer 1


You need to iterate the datasets to get his containing feature classes. Like this:

While Not pSdeDSName Is Nothing
    Dim pEnumDataset = pSdeDSName.Subsets
    Dim pSubset = pEnumDataset.Next()
    While Not pSubset Is Nothing
        If pSubset.Type = ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTFeatureClass Then
        End If
    End While
End While

The code is not tested, I'm used to C#, but you get the idea.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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