4

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
 Try
 If TypeOf pGxObject Is ESRI.ArcGIS.Catalog.IGxDatabase2 Then
 pGxDatabase = pGxObject
 pWorkspace = pGxDatabase.Workspace
 System.Windows.Forms.MessageBox.Show(pWorkspace.PathName)
 Else
 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
 ListBox1.Items.Add(pSdeDSName.Name)
 pSdeDSName = pEnumDSName.Next
 End While
 Catch ex As Exception
 System.Windows.Forms.MessageBox.Show(ex.ToString, "GetWorkspace")
 End Try
End Sub
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Aug 4, 2016 at 6:59

1 Answer 1

5

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
 ListBox1.Items.Add(pSubset.Name)
 End If
 End While
End While

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

answered Aug 4, 2016 at 9:13
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.