Hide individual features in ArcMap featurelayer

8168
7
10-10-2011 06:43 AM
OlaRennemo
New Contributor III
Hi all,
I am developing a toolbar/extension for ArcMap.

I want to make certain features invisible in the map, so I define featurelayer symbology based on values in one field. When setting the value outside the range, the feature is hidden. So far so good.

But the user can still select the same feature using ArcMaps select tool. Can this be preventet in some way? Are there other methods for controlling feature visibility?
(Note: I do NOT want to delete the content of the geometry column, because it must be possible to "undelete" the feature later.)

Any suggestions ?

TIA
Ola
0 Kudos
7 Replies
JamesCrandall
MVP Frequent Contributor
Ola,

Are you saying that when you toggle the layer's visibility off, you can still see the selected features?

If so, then it might be that you need to do a full refresh on the ActiveView:

'This line would refresh the selection
pDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, Nothing, Nothing)
'add this line to fully refresh the view
pDoc.ActiveView.Refresh()
0 Kudos
OlaRennemo
New Contributor III
The layer itself is set to visible, but I am trying to hide individual features within, based on some attribute values, and even hide them the from ArcMap's selection tool.


Ola,

Are you saying that when you toggle the layer's visibility off, you can still see the selected features?

If so, then it might be that you need to do a full refresh on the ActiveView:

'This line would refresh the selection
pDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, Nothing, Nothing)
'add this line to fully refresh the view
pDoc.ActiveView.Refresh()
0 Kudos
JamesCrandall
MVP Frequent Contributor
The layer itself is set to visible, but I am trying to hide individual features within, based on some attribute values, and even hide them the from ArcMap's selection tool.


So you are invoking a DefinitionQuery on a featureLayer?

The default behavior seems to be that the selected feature should not show if included in the definition query filter.  Perhaps it is something specific with your code that is producing the behavior you are seeing.

Post up the code you have so far.
0 Kudos
OlaRennemo
New Contributor III
So you are invoking a DefinitionQuery on a featureLayer?

The default behavior seems to be that the selected feature should not show if included in the definition query filter.  Perhaps it is something specific with your code that is producing the behavior you are seeing.

Post up the code you have so far.


I guess a queryfilter in the featurelayer would do the trick, but cannot find out how... The examples I find are related to the ArcIMS API, and I cant find similar methods here...
Could you give me a hint where to start?
0 Kudos
JamesCrandall
MVP Frequent Contributor
I guess a queryfilter in the featurelayer would do the trick, but cannot find out how... The examples I find are related to the ArcIMS API, and I cant find similar methods here...
Could you give me a hint where to start?


It would look something like this:

Dim pFLayer As IFeatureLayer = pMap.Layer(0)
Dim pDefQ As IFeatureLayerDefinition
pDefQ = pFLayer
pDefQ.DefinitionExpression = "OBJECTID = " & 11420  'I just set this for testing an Integer value

'altered to query a string field
pDefQ.DefinitionExpression = "SomeStringField = '" & someStringValue & "'"  
0 Kudos
OlaRennemo
New Contributor III
It would look something like this:

Dim pFLayer As IFeatureLayer = pMap.Layer(0)
Dim pDefQ As IFeatureLayerDefinition
pDefQ = pFLayer
pDefQ.DefinitionExpression = "OBJECTID = " & 11420  'I just set this for testing an Integer value

'altered to query a string field
pDefQ.DefinitionExpression = "SomeStringField = '" & someStringValue & "'"  


That's it, thanks a lot!
As often before, the solution is quite simple as long as you can find the right interfaces and examples. Which reminds me that the current help system, connected to the VisualStudio, usually answers everything I am NOT looking for...
0 Kudos
JamesCrandall
MVP Frequent Contributor
That's it, thanks a lot!
As often before, the solution is quite simple as long as you can find the right interfaces and examples. Which reminds me that the current help system, connected to the VisualStudio, usually answers everything I am NOT looking for...


Excellent!

tip: I get more successful searches at the old/archived forums still.

http://forums.esri.com/forums.asp?c=93
0 Kudos