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
The Attributes Inspector window updates automatically when a user selects a feature with a tool on the map. However, this may not be true when a feature is selected programmatically.
The following sample illustrates how to select a feature programmatically and to update the Attributes Inspector. The key is to use ISelectionEvents to notify the Attributes Inspector.
Note: For more information on creating a UIControl, see the ArcGIS Desktop Help topic 'Creating custom commands with VBA and UI Controls'
Dim pMxDoc As IMxDocument Dim pMap As IMap Dim pFSel As IFeatureSelection ' Build a query to select the first feature Dim pQF As IQueryFilter Set pQF = New QueryFilter pQF.WhereClause = "Fid = 1" Dim pFeatCur As IFeatureCursor ' Return a reference to the map Set pMxDoc = ThisDocument Set pMap = pMxDoc.FocusMap ' Clear the prior selection pMap.ClearSelection ' Select a feature Set pFSel = pMap.Layer(0) pFSel.SelectFeatures pQF, esriSelectionResultNew, False 'Refresh the Active View Dim pAV As IActiveView Set pAV = pMap pAV.PartialRefresh 2, pFSel, Nothing ' **************************************
Dim pSelEvents As ISelectionEvents Set pSelEvents = pMap pSelEvents.SelectionChanged
Get help from ArcGIS experts
Download the Esri Support App