Private Sub btnCatch_Click() 'Allow the user to select the catchments feature class Dim pGxDialog As IGxDialog Set pGxDialog = New GxDialog pGxDialog.Title = "Select Catchments Feature Class" pGxDialog.ButtonCaption = "Select" pGxDialog.AllowMultiSelect = False pGxDialog.StartingLocation = "Catalog" Dim pGxFilter As IGxObjectFilter Set pGxFilter = New GxFilterPolygonFeatureClasses Set pGxDialog.ObjectFilter = pGxFilter Dim pLayerFiles As IEnumGxObject pGxDialog.DoModalOpen 0, pLayerFiles Dim pLayerFile As IGxObject Set pLayerFile = pLayerFiles.Next 'Display the name of the selected feature class in the text box txtboxSelectedFC.Text = pLayerFile.Name 'Populate combobox with the field names from that feature class Dim pGxFile As IGxFile Set pGxFile = New GxFile pGxFile.Path = pLayerFile.FullName Dim pGxLayer As IGxLayer End Sub
Solved! Go to Solution.
Dim pGxDialog As IGxDialog Set pGxDialog = New GxDialog pGxDialog.Title = "Select Catchments Feature Class" pGxDialog.ButtonCaption = "Select" pGxDialog.AllowMultiSelect = False pGxDialog.StartingLocation = "Catalog" Dim pGxFilter As IGxObjectFilter Set pGxFilter = New GxFilterPolygonFeatureClasses Set pGxDialog.ObjectFilter = pGxFilter Dim pLayerFiles As IEnumGxObject pGxDialog.DoModalOpen 0, pLayerFiles Dim pLayerFile As IGxObject Set pLayerFile = pLayerFiles.Next Dim pFLayer As IFeatureLayer Set pFLayer = New FeatureLayer Set pFLayer.FeatureClass = pLayerFile.InternalObjectName.Open Dim pFields As IFields Set pFields = pFLayer.FeatureClass.Fields Dim i As Integer For i = 0 To pFields.FieldCount - 1 ComboBox1.AddItem pFields.Field(i).Name Next
Dim pGxDialog As IGxDialog Set pGxDialog = New GxDialog pGxDialog.Title = "Select Catchments Feature Class" pGxDialog.ButtonCaption = "Select" pGxDialog.AllowMultiSelect = False pGxDialog.StartingLocation = "Catalog" Dim pGxFilter As IGxObjectFilter Set pGxFilter = New GxFilterPolygonFeatureClasses Set pGxDialog.ObjectFilter = pGxFilter Dim pLayerFiles As IEnumGxObject pGxDialog.DoModalOpen 0, pLayerFiles Dim pLayerFile As IGxObject Set pLayerFile = pLayerFiles.Next Dim pFLayer As IFeatureLayer Set pFLayer = New FeatureLayer Set pFLayer.FeatureClass = pLayerFile.InternalObjectName.Open Dim pFields As IFields Set pFields = pFLayer.FeatureClass.Fields Dim i As Integer For i = 0 To pFields.FieldCount - 1 ComboBox1.AddItem pFields.Field(i).Name Next
Public Sub Test() ' Create dialog Dim pGxDialog As IGxDialog Set pGxDialog = New GxDialog ' Define filter Dim pGxObjectFilter As IGxObjectFilter Set pGxObjectFilter = New GxFilterPolygonFeatureClasses ' Set dialog properties and open Dim pEnumGxObject As IEnumGxObject With pGxDialog .Title = "Select Catchments Feature Class" .ButtonCaption = "Select" .AllowMultiSelect = False .StartingLocation = "Catalog" Set .ObjectFilter = pGxObjectFilter .DoModalOpen 0, pEnumGxObject End With Dim pGXObject As IGxObject Set pGXObject = pEnumGxObject.Next Dim pGXdataset As IGxDataset Set pGXdataset = pGXObject Dim pDataset As IDataset Set pDataset = pGXdataset.Dataset Dim pFeatureClass As IFeatureClass Set pFeatureClass = pDataset ' Get fields a cycle through them Dim pFields As IFields Set pFields = pFeatureClass.Fields Dim i As Byte Dim pField As IField For i = 0 To pFields.FieldCount - 1 Set pField = pFields.Field(i) MsgBox pField.Name Next i End Sub