Transferred from the original C # arcgisengine development, filtering a layer to show only those features that match the criteria
Sometimes, we want to have a selective display of the figures on the layer to meet the actual functional requirements.
The Layer Properties filter display is easy to implement as described in the following methods:
1. When the layer is loaded
String sfilter) { ESRI. ArcGIS.Carto.IFeatureLayerDefinition pdef = (ESRI. ArcGIS.Carto.IFeatureLayerDefinition) Sflyr; Pdef.definitionexpression = sfilter; SMapCtr.ActiveView.Refresh ();}
2. When the layer is not loaded
Private Ifeatureclass Getfeatureclass (Iworkspace PWS,String Stabname,StringSattrfilter) {Try{if (PWS = =null | | Stabname = =NullReturnNull; Ifeatureworkspace PFWS = PWSAsIfeatureworkspace; Ifeatureclass PFC =Null; PFC =Pfws.openfeatureclass (Stabname); Iquerydef Pquerydef =Pfws.createquerydef (); Pquerydef.tables =Stabname; Pquerydef.whereclause =Sattrfilter; IQueryName2 Pqueryname =NewFeaturequerynameclass (); Pqueryname.primarykey =pfc.oidfieldname; pqueryname.querydef = pquerydef; Idataset PDS = (idataset) Pfws; Iworkspacename pwsname = (iworkspacename) pds.fullname; Idatasetname pdsname = (idatasetname) pqueryname; pdsname.workspacename = pwsname; Iname pName = (iname) pqueryname; PFC = Pname.open () as Ifeatureclass; return PFC;} catch { return null;}}
In C # arcgisengine development, a layer is filtered to show only those features that match the criteria