HOW TO
Note: Support for Visual Basic for Applications (VBA) for ArcMap and ArcCatalog ended with the ArcGIS 10.2.2 release, and Esri has not included VBA compatibility setups since version 10.5. See: ArcGIS Desktop and VBA Moving Forward
When calling the PartialRefresh method on the IActiveView interface to update the display with a newly selected feature, ythe change may not be reflected in the display. That is because IActiveView::PartialRefresh must be called twice, once before IMap::ClearSelection and once after.
Note: This article pertains to ArcGIS versions 8.x. Later versions of ArcGIS may contain different functionality, as well as different names and locations for menus, commands and geoprocessing tools.
This VBA sample code illustrates how to call IActiveView::PartialRefresh both before and after IMap::ClearSelection to update the display correctly.
Note: For more information on creating a UIControl, see the ArcGIS Desktop Help topic: 'Creating custom commands with VBA and UI Controls'
Dim pApp As IApplication Set pApp = Application Dim pMxDoc As IMxDocument Set pMxDoc = ThisDocument Dim pMap As IMap Set pMap = pMxDoc.ActiveView Dim pFeatLay As IFeatureLayer Set pFeatLay = pMap.Layer(0) Dim pFeatCursor As IFeatureCursor Set pFeatCursor = pFeatLay.Search(Nothing, False) Dim pFeat As IFeature Set pFeat = pFeatCursor.NextFeature Dim pAV As IActiveView Set pAV = pMap ' ***** When PartialRefresh isn't called ' before ClearSelection, the Map does not refresh correctly. ' pAV.PartialRefresh esriViewGeoSelection, pFeatLay, Nothing ' ***** pMap.ClearSelection pMap.SelectFeature pFeatLay, pFeat pAV.PartialRefresh esriViewGeoSelection, pFeatLay, Nothing
' ***** When PartialRefresh isn't called ' before ClearSelection, the Map does not refresh correctly. ' pAV.PartialRefresh esriViewGeoSelection, pFeatLay, Nothing ' ******
Get help from ArcGIS experts
Download the Esri Support App