Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am currently using the following method 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
add comment

2 Answers 2

up vote 2 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
add comment
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
    Else
        Exit Sub
    End If
share|improve this answer
add comment

Your Answer

 
discard

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.