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
Private void string sfilter) { = (ESRI. ArcGIS.Carto.IFeatureLayerDefinition) Sflyr; = sfilter; SMapCtr.ActiveView.Refresh (); }
2. When the layer is not loaded
PrivateIfeatureclass Getfeatureclass (Iworkspace PWS,stringStabname,stringsattrfilter) { Try { if(PWS = =NULL|| Stabname = =NULL)return NULL; Ifeatureworkspace Pfws= PWS asIfeatureworkspace; 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 () asIfeatureclass; returnPFC; } Catch { return NULL; } }
"Go" in C # arcgisengine development, a layer is filtered to show only those features that match the criteria