根据某一属性值查找IFeature

  1. //给定图层,字段及一个值,查找Feature对象,
  2. //参数列表: pLayer----------图层
  3. //strFldName------字段名
  4. //strFldValue-----属性值
  5. public IFeature FindFeature(ILayer pLayer, string strFldName, string strFldValue)
  6. {
  7. IFeatureLayer featLyr = pLayer as IFeatureLayer;
  8. IFeatureClass featCls = featLyr.FeatureClass;
  9. IFeatureCursor featCur;
  10. IFeature feat;
  11. IQueryFilter pFliter = new QueryFilterClass();
  12. pFliter.WhereClause = strFldName + "=" + "'" + strFldValue + "'";
  13. featCur = featCls.Search(pFliter, false);
  14. feat = featCur.NextFeature();
  15. return feat;
  16. }

    推荐阅读