参考了网上大量方法,都能成功运行
方法1:实现新建查询图层,查询结果要素为选中状态
思路:新建IFeatureSelection接口,选中图层要素,利用IQueryFilter创建过滤器,设置查询条件,IFeatureLayerDefinition创建查询图层,最后添加到map中去
引用
using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Controls; using
ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.Geometry; using
ESRI.ArcGIS.SystemUI; using System; using System.IO;
usingSystem.Windows.Forms;
主要实现代码:
ILayer pLayer = (ILayer)axMapControl1.Map.get_Layer(0);
IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
//QI到FeatureSelection
IFeatureSelection pFeatureSelection = pFeatureLayer as IFeatureSelection;