How to get the definition query of a layer in ArcMap from an AddIn tool's code?

569
1
05-04-2023 05:24 AM
Gurunara
New Contributor III

A little new to ArcObject's SDK... Is this the place to create the post?
Need to access the definition query of a layer that the user created in the ArcMap application (if the layer exists) from an addin tool's code. Need to access this definition query and apply it to a search/query.

Is there a sample code/example for this?

0 Kudos
1 Reply
BrentHoskisson
Occasional Contributor III

You have to query inteface to IFeatureLayerDefinition2:

 

IFeatureLayerDefinition2 ifld = (IFeatureLayerDefinition2)layer;
string defquery = ifld.DefinitionExpression;

 

Brent Hoskisson

 

0 Kudos