ArcGIS Engine中删除要素的几种方法

方法1

/// 通过IFeature.Delete方法删除要素  
///   
/// 要素类  
/// 查询条件  
public static void DeleteFeatureByIFeature(IFeatureClass pFeatureclass, string strWhereClause)  
{  
    IQueryFilter pQueryFilter = new QueryFilterClass();  
    pQueryFilter.WhereClause = strWhereClause;  
    IFeatureCursor pFeatureCursor = pFeatureclass.Search(pQueryFilter, false);  
    IFeature pFeature = pFeatureCursor.NextFeature();  
    while (pFeature != null)  
    {  
        pFeature.Delete();  
        pFeature = pFeatureCursor.NextFeature();  
    }  
}  

方法2

/// 通过IFeatureCursor.DeleteFeature方法删除要素  
 ///   
 /// 要素类  
 /// 查询条件  
 public static void DeleteFeatureByIFeatureCursor(IFeatureClass pFeatureclass, string strWhereClause)  
 {  
     IQueryFilter pQueryFilter = new QueryFilterClass();  
     pQueryFilter.WhereClause = strWhereClause;  
     IFeatureCursor pFeatureCursor = pFeatureclass.Update(pQueryFilter, false);  
     IFeature pFeature = pFeatureCursor.NextFeature();  
     while (pFeature != null)  
     {  
         pFeatureCursor.DeleteFeature();  
         pFeature = pFeatureCursor.NextFeature();  
     }  
 }

方法3

///   
/// 通过ITable.DeleteSearchedRows方法删除要素  
///   
/// 要素类  
/// 查询条件  
public static void DeleteFeatureByITable(IFeatureClass pFeatureclass, string strWhereClause)  
{  
    IQueryFilter pQueryFilter = new QueryFilterClass();  
    pQueryFilter.WhereClause = strWhereClause;  
    ITable pTable = pFeatureclass as ITable;  
    pTable.DeleteSearchedRows(pQueryFilter);  
}  

你可能感兴趣的:(ArcGIS,C#)