Open All files in a GDB

677
2
12-10-2012 03:54 AM
TitoCalata
New Contributor
Hello!
First of all, sorry but my English. Well, I would like to make a question about how can I add all the layers of a geodatabe in my ArcGIS

I'm creating a form with VB.Net, and I created a button that I would like when I pressed it the layers were added (preferrably not visible) in Arcgis.
Right now, I just achieved to add just one layer....
Here is my code:
Private Sub cmdConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConnect.Click
        MxDoc = My.ArcMap.Document
        MapFrame = MxDoc.FocusMap
        Dim i As Integer
        Dim intMapCount As Integer
        Wfactory = New FileGDBWorkspaceFactory
        Work = Wfactory.OpenFromFile("C:\Information.gdb", 0)
        FWorkspace = Work
        FData = FWorkspace.OpenFeatureClass("Fields")
        Flayer = New FeatureLayer
        Flayer.FeatureClass = FData
        Flayer.Name = Flayer.FeatureClass.AliasName
        MapFrame.AddLayer(Flayer)
        MxDoc.ActivatedView.Refresh()
    End Sub


So, inside Information.gdb, I have 3 layers(Fields, Boundary and Others), how can I add these 3 layers?.

thank you!
0 Kudos
2 Replies
SteveFang
New Contributor III
Hi,

Your work variable should be of type IWorkspace.  On that interface is the DatasetNames method which returns the IEnumDatasetName which is of type IDatasetName.  Now you have the names for all your featureclasses so you can loop though them and sent the name to your IFeatureWorkspace.Openfeatureclass method.  Hope that helps.

Steve
0 Kudos
TitoCalata
New Contributor
Thank you Steve!! I'm going to try it
0 Kudos