I am an amateur in arcgis development so i have come here for some light into the issue i am facing. First of all i have a layer called GridSheet whose attribute table is as shown below:
The corresponding map looks like the following:
I was able to select all the surrounding grids by the following code. Now, i want to get the corresponding table rows of the selected grid boxes. From the rows i want to extract the MapSheetNumber of the selected boxes or sheets. How can i do that?
'*** Selects the center grid box or cell
SelectFeatureInMap(pGridFeatureLayer, pQFilter)
'*** Then the following code will select all boxes that touch the above center box
Dim pFeatureLayer As IFeatureLayer
pFeatureLayer = pGridFeatureLayer
Dim pLayer As IFeatureSelection
Dim pSelection As ISelectionSet
Dim pCursor As IFeatureCursor
pLayer = pFeatureLayer
pSelection = pLayer.SelectionSet
Dim pEnumIds As IEnumIDs
pEnumIds = pSelection.IDs
pSelection.Search(Nothing, True, pCursor)
pFeature = pCursor.NextFeature
If pFeature Is Nothing Then
Exit Sub
End If
Dim geometryBag As IGeometryBag = New GeometryBagClass()
Dim geometryCollection As IGeometryCollection = CType(geometryBag, IGeometryCollection)
Dim geoDataset As IGeoDataset = CType(pFeatureLayer.FeatureClass, IGeoDataset)
Dim spatialReference As ISpatialReference = geoDataset.SpatialReference
geometryBag.SpatialReference = spatialReference
While Not pFeature Is Nothing 'Add all the polygons selected to the geometry bag
geometryCollection.AddGeometry(pFeature.Shape)
pFeature = pCursor.NextFeature
End While
Dim pSpatialFilter As ISpatialFilter
pSpatialFilter = New SpatialFilterClass
pSpatialFilter.Geometry = geometryBag
pSpatialFilter.GeometryField = pFeatureLayer.FeatureClass.ShapeFieldName
pSpatialFilter.SubFields = "Shape"
pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelTouches
pFL = pLayer
pFClass = pFL.FeatureClass
pSelection = pFClass.Select(pSpatialFilter, esriSelectionType.esriSelectionTypeHybrid, esriSelectionOption.esriSelectionOptionNormal, Nothing)
Dim noCount As Short
pSelection.Add(pEnumIds.Next)
noCount = pSelection.Count
pLayer.SelectFeatures(pSpatialFilter, esriSelectionResultEnum.esriSelectionResultNew, False)
pMxDoc.ActiveView.Refresh()
I appreciate your help if you can point to me in the right direction. Thanks a lot!!