private void ClearAllFeature(string tempLayerName)
{
Catalog cat = MapInfo.Engine.Session.Current.Catalog;
SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("");
IResultSetFeatureCollection ifs;
MapInfo.Data.Table Tm;
Tm = cat.GetTable(tempLayerName);
if (Tm != null) //Table exists close it
{
si = MapInfo.Data.SearchInfoFactory.SearchWhere("");
ifs = MapInfo.Engine.Session.Current.Catalog.Search(tempLayerName, si);
if (MessageBox.Show("确定清除所有的图元吗", "确认", MessageBoxButtons.OKCancel) == DialogResult.OK)
{
foreach (Feature ft in ifs)
{
Tm.DeleteFeature(ft);//清除所有该图层上的图元
}
}
this.mapMainControl.Refresh(); //刷新地图
}
}