Private Sub zoomFeature(ByVal objectID As String) Dim pQueryFilter As IQueryFilter Dim pFeatureLayer As IFeatureLayer Dim pFeatureSelection As IFeatureSelection Dim pLayer As ILayer Dim intCount As Integer For intCount = 0 To AxMapControl1.LayerCount - 1 pLayer = AxMapControl1.Map.Layer(intCount) If TypeOf pLayer Is IFeatureLayer Then pFeatureLayer = pLayer '<---Implicit conversion from 'ESRI.ArcGIS.Carto.ILayer' to 'ESRI.ArcGIS.Carto.IFeatureLayer' pFeatureSelection = pFeatureLayer '<---Implicit conversion from 'ESRI.ArcGIS.Carto.IFeatureLayer' to 'ESRI.ArcGIS.Carto.IFeatureSelection' If pFeatureLayer.Name = "DistrictBoundary" Then 'Create the query filter pQueryFilter = New QueryFilter '<---Implicit conversion from 'ESRI.ArcGIS.Geodatabase.QueryFilterClass' to 'MapControlApplication1.QueryFilter' pQueryFilter.WhereClause = "OBJECTID = " & objectID '<--- 'WhereClause' is not a member of 'MapControlApplication1.QueryFilter' AxMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing) pFeatureSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, False) '<---Implicit conversion from 'MapControlApplication1.QueryFilter' to 'ESRI.ArcGIS.Geodatabase.IQueryFilter' End If End If End Sub
Solved! Go to Solution.
Cast?
http://www.codeproject.com/Articles/5044/Cheat-Sheet-Casting-in-VB-NET-and-C
Option Strict Off Imports System.Data.OleDb Imports System.Drawing .....
Private Sub SelectFeatureZoom(ByVal NAM As String) Dim pQueryFilter As ESRI.ArcGIS.Geodatabase.IQueryFilter = New ESRI.ArcGIS.Geodatabase.QueryFilterClass Dim pFeatureLayer As IFeatureLayer Dim pFeatureSelection As IFeatureSelection Dim pLayer As ILayer Dim intCount As Integer For intCount = 0 To AxMapControl1.LayerCount - 1 pLayer = AxMapControl1.Map.Layer(intCount) If TypeOf pLayer Is IFeatureLayer Then pFeatureLayer = pLayer pFeatureSelection = pFeatureLayer If pFeatureLayer.Name = "DistrictBoundary" Then 'Create the query filter & select feature pQueryFilter.WhereClause = " NAM = " & "'" & ComboBox1.Text & "'" AxMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing) pFeatureSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, False) End If End If Next 'Then Zoom Dim pFeature As IFeature Dim pEnvelope As IEnvelope Dim pArea As IArea Dim pEnumFeat As IEnumFeature pEnumFeat = AxMapControl1.ActiveView.FocusMap.FeatureSelection pFeature = pEnumFeat.Next pEnvelope = pFeature.Shape.Envelope.Envelope If pFeature.Shape.GeometryType = esriGeometryType.esriGeometryPoint Or (pEnvelope.Width = 0 And pEnvelope.Height = 0) Then If AxMapControl1.ActiveView.FocusMap.ReferenceScale <> 0.0 Then AxMapControl1.ActiveView.FocusMap.MapScale = AxMapControl1.ActiveView.FocusMap.ReferenceScale / 3 pEnvelope = AxMapControl1.ActiveView.Extent pArea = pFeature.Shape.Envelope pEnvelope.CenterAt(pArea.Centroid) Else pEnvelope = AxMapControl1.ActiveView.Extent pArea = pFeature.Shape.Envelope pEnvelope.CenterAt(pArea.Centroid) pEnvelope.Expand(2, 2, True) End If AxMapControl1.ActiveView.Extent = pEnvelope AxMapControl1.ActiveView.Refresh() Else AxMapControl1.ActiveView.Extent = pFeature.Extent AxMapControl1.ActiveView.Refresh() End If End Sub