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?
-
when you say "files" what do you mean? Do you mean feature classes?Rob Clark– Rob Clark2011年04月27日 16:00:32 +00:00Commented Apr 27, 2011 at 16:00
2 Answers 2
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.
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
-
Is it possible to filter for specific (i.e. .xml) or custom (i.e. .lmnop) extensions, or are we limited to what is available in Catalog?Barbarossa– Barbarossa2019年03月27日 20:02:23 +00:00Commented Mar 27, 2019 at 20:02
Explore related questions
See similar questions with these tags.