How do I just refresh one feature layer using PartialRefresh

1162
1
01-13-2017 06:16 AM
LimingWu
New Contributor II

Hello,

I'm creating an ArcMap add-in for dynamically updating a feature layer. My map have many other layers. Every time I call ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, myFeatureLayer, null), all other layers are refreshed as well. How can I just refresh my layer? Thanks.

Tags (1)
0 Kudos
1 Reply
DuncanHornby
MVP Notable Contributor

If you look at the help file for IActiveView it is fairly clear that you need to ensure that the individual layers have their cached property set to True for partial refresh to take affect. Below is some VBA code to show you how to set this:

Public Sub test()
 Dim pMXDocument As IpMXDocumentocument
 Set pMXDocument = ThisDocument
 
 Dim pMap As IMap
 Set pMap = pMXDocument.FocusMap
 
 Dim pLayer As ILayer
 Set pLayer = pMap.Layer(0)
 
 Dim pActiveView As IActiveView
 Set pActiveView = pMXDocument.ActiveView
 
 ' whole screen refreshes
 pActiveView.PartialRefresh esriViewGeography, pLayer, Nothing
MsgBox "now cached refresh"
 
 ' Ensure individual layer is cashed
 pLayer.Cached = True
 pActiveView.PartialRefresh esriViewGeography, pLayer, Nothing
End Sub‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

As a side note questions related to ArcObjects should be tagged as ArcObjects or posted in the ArcObjects SDK, you are more likely to capture the attention of the right sort of person.

0 Kudos