博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

AE中删除属性字段

Posted on 2011-02-23 14:49  星尘的天空  阅读(526)  评论(0编辑  收藏  举报

        /// <summary>
        /// 删除字段值
        /// </summary>
        /// <param name="pCurrentLayer"></param>
        /// <param name="fieldName"></param>
        public static bool DeleteILayerField(ILayer pCurrentLayer, string fieldName)
        {
            try
            {
                IFeatureLayer pFeatureLayer = (IFeatureLayer)pCurrentLayer;
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                //
                int pFieldIndex = pFeatureClass.FindField(fieldName);
                IFields pFields = pFeatureClass.Fields;
                IField pField = pFields.get_Field(pFieldIndex);
                if (pField != null)
                {
                    pFeatureClass.DeleteField(pField);
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

剩下的就是根据需要刷新数据,显示删除后的Fields信息