Hi prahlad1981,I tried it but the same problem, what can I do??Thanks for your assistance
Hi prahlad1981,Yes the error appeared in this line so I tried my previous code but it zoomed to nothing and the map control became blank !!!Here's my final code: Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Try pActiveview = AxPageLayoutControl1.ActiveView Dim pMap, pmap2 As IMap pmap2 = pActiveview.FocusMap pMap = AxTOCControl1.ActiveView.FocusMap pmap2.ClearSelection() pActiveview.Refresh() If Not TypeOf pMap.Layer(0) Is IFeatureLayer Then Exit Sub pfeatureLayer = pMap.Layer(0) pfeatureselection = pfeatureLayer 'QI Dim where As String where = "GeoCode2 = '" & Blocks_List.SelectedItem & "'" If Not pfeatureselection Is Nothing Then Dim pQueryFilter As IQueryFilter = New QueryFilterClass() pQueryFilter.WhereClause = where pfeatureselection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, False) Dim pSelSet As ISelectionSet pSelSet = pfeatureselection.SelectionSet Dim pEnumGeom As IEnumGeometry Dim pEnumGeomBind As IEnumGeometryBind pEnumGeom = New EnumFeatureGeometry pEnumGeomBind = pEnumGeom pEnumGeomBind.BindGeometrySource(Nothing, pSelSet) Dim pGeomFactory As IGeometryFactory pGeomFactory = New GeometryEnvironment Dim pGeom As IGeometry pGeom = pGeomFactory.CreateGeometryFromEnumerator(pEnumGeom) AxPageLayoutControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing) AxPageLayoutControl1.ActiveView.Extent = pGeom.Envelope AxPageLayoutControl1.ActiveView.Refresh() End If Catch ex As Exception MsgBox(ex.Message) End Try End SubThank you very much
Hi prahlad1981,Thanks for your replyI have made some changes in the code that I wrote procedure for select features and another one for the zoom then I try your suggestion but the following error appeared:this is the code: Public Sub SelectFeatures() Try pActiveview = AxPageLayoutControl1.ActiveView Dim pMap, pmap2 As IMap pmap2 = pActiveview.FocusMap pMap = AxTOCControl1.ActiveView.FocusMap pmap2.ClearSelection() pActiveview.Refresh() If Not TypeOf pMap.Layer(0) Is IFeatureLayer Then Exit Sub pfeaturelayer = pMap.Layer(0) pFeatureSelection = pfeaturelayer 'QI Dim where As String where = "GeoCode2 = '" & Blocks_List.SelectedItem & "'" If Not pFeatureSelection Is Nothing Then Dim pQueryFilter As IQueryFilter = New QueryFilterClass() pQueryFilter.WhereClause = where pFeatureSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, False) AxPageLayoutControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing) End If Catch ex As Exception MsgBox(ex.Message) End Try End Sub Public Sub ZoomToSelectedFeatures() Dim pMap As IMap pActiveview = AxPageLayoutControl1.ActiveView pMap = pActiveview.FocusMap Dim pFSel As IFeatureSelection pFSel = pMap.FeatureSelection() Dim pSelSet As ISelectionSet pSelSet = pFSel.SelectionSet Dim pEnumGeom As IEnumGeometry Dim pEnumGeomBind As IEnumGeometryBind pEnumGeom = New EnumFeatureGeometry pEnumGeomBind = pEnumGeom pEnumGeomBind.BindGeometrySource(Nothing, pSelSet) Dim pGeomFactory As IGeometryFactory pGeomFactory = New GeometryEnvironment Dim pGeom As IGeometry pGeom = pGeomFactory.CreateGeometryFromEnumerator(pEnumGeom) pActiveview.Extent = pGeom.Envelope AxMapControl1.ActiveView.FocusMap.MapScale = 1250 AxPageLayoutControl1.ActiveView.FocusMap.MapScale = 1250 AxMapControl1.Refresh() AxPageLayoutControl1.Refresh() End Sub Private Sub Blocks_List_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Blocks_List.SelectedIndexChanged SelectFeatures() End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Try ZoomToSelectedFeatures() Catch ex As Exception MsgBox(ex.Message) End Try End Sub
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.