Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently using the following method with ArcGIS 10 to open raster files from a form:

Public Function BrowseRaster(ByVal sTitle As String, ByRef sFolder As String, ByRef sName As String) As Boolean

 Dim pGxDialog As IGxDialog = New GxDialog
    Dim pRasterFilter As IGxObjectFilter = New GxFilterRasterDatasets()

    Dim pFilterCol As IGxObjectFilterCollection
    Dim pEnumGx As IEnumGxObject
    Dim pGxObject As IGxObject

    sFolder = ""
    sName = ""

    pFilterCol = pGxDialog
    pFilterCol.AddFilter(pRasterFilter, True)
    'pGxDialog.StartingLocation = ""
    pGxDialog.RememberLocation = True
    pGxDialog.AllowMultiSelect = False
    pGxDialog.Title = sTitle

        If pGxDialog.DoModalOpen(0, pEnumGx) Then
            pGxObject = pEnumGx.Next
            Dim sFile As New FileInfo(pGxObject.FullName)
            'sName = pGxObject.BaseName
            sName = pGxObject.Name
            sFolder = sFile.Directory.FullName
            Return True
        End If

End Function

How can I modify this function to also open files from inside of a file geodatabase?

share|improve this question
when you say "files" what do you mean? Do you mean feature classes? – Rob Clark Apr 27 '11 at 16:00
up vote 3 down vote accepted

Look at the very bottom of the list of objects that implement IGxObjectFilter

Create instances of RasterFormatFGDBFilter, RasterFormatPGDBFilter and RasterFormatSDEFilter and add them to your IGxObjectFilterCollection. This will enable Rasters inside GDBs. If you want to allow other FeatureClasses to be opened look at the list and also add those filters.

share|improve this answer
Dim pRasterFilter As IGxObjectFilter = New GxFilterRasterDatasets()

Just modify the filter. Look at IGxObjectFilter interface help for a list of available filters. For example to filter for Feeature Datasets you could use:

    Dim pGxDialog As IGxDialog
    Dim pGxObjFilter As IGxObjectFilter
    Dim pEnumGxObj As IEnumGxObject = Nothing

    pGxDialog = New GxDialog
    pGxObjFilter = New GxFilterFeatureDatasets
    pGxDialog.ObjectFilter = pGxObjFilter
    pGxDialog.Title = "Select a Dataset containing Feature Classes"
    pGxDialog.ButtonCaption = "OK"

    If pGxDialog.DoModalOpen(0, pEnumGxObj) Then
        pGxObj = pEnumGxObj.Next
        pGxDataset = pGxObj
        Me.txtDataset.Text = pGxObj.FullName
        Exit Sub
    End If
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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