0
点赞
收藏
分享

微信扫一扫

定义查询(根据字段内容显示要素)

yongxinz 2022-03-30 阅读 30
  public static void ShowFeaturesByFieldValue(this IFeatureLayer pFeatureLayer, string filedName, string value)
        {
            if (pFeatureLayer == null)
            {
                return;
            }
            ESRI.ArcGIS.Carto.IFeatureLayerDefinition pDef = (ESRI.ArcGIS.Carto.IFeatureLayerDefinition)pFeatureLayer;
            IActiveView activeView = ArcMap.Document.FocusMap as IActiveView;
            string mWhere = string.Empty;
            if (value.Length == 0)
            {
                mWhere = "";
            }
            else
            {
                mWhere = filedName + "='" + value + "'";
            }
            //清除现有选择
            pDef.DefinitionExpression = "";
            activeView.Refresh();
            pDef.DefinitionExpression = mWhere;
            activeView.Refresh();
        }


        public static void ShowFeaturesByFieldValue(IMap map, IFeatureLayer pFeatureLayer, string filedName, string value)
        {
            ESRI.ArcGIS.Carto.IFeatureLayerDefinition pDef = (ESRI.ArcGIS.Carto.IFeatureLayerDefinition)pFeatureLayer;
            IActiveView activeView = map as IActiveView;
            string mWhere = string.Empty;
            if (value.Length == 0)
            {
                mWhere = "";
            }
            else
            {
                mWhere = filedName + "='" + value + "'";
            }
            //清除现有选择
            pDef.DefinitionExpression = "";
            activeView.Refresh();
            pDef.DefinitionExpression = mWhere;
            activeView.Refresh();
        }
举报

相关推荐

0 条评论