在数据量较大时,不亦使用MapControl.Refresh()方法,这会使得所有数据重新加载,所以建议使用ActiveView.PartialRefresh()的方式来部分刷新,在项目中,常遇到要选中并高亮显示某个feature的情况,具体做法如下:
ESRI.ArcGIS.Carto.ILayer layer = axMapControl1.get_Layer(0);
ESRI.ArcGIS.Carto.IFeatureSelection selection = layer as ESRI.ArcGIS.Carto.IFeatureSelection;
ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
filter.WhereClause = "ID IN ('P0038', 'P0039')";//要高亮的feature的Id
axMapControl1.ActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, layer, null);//刷新feature所在的图层
selection.Clear();//清除以前的高亮
selection.SelectFeatures(filter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew, false);//新的高亮
axMapControl1.ActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, layer, null);//刷新feature所在的图层
需要注意的是,我在程序中调用了两次PartialRefresh(),这个不是多余,因为要selection.Clear()的前后分别执行一次PartialRefresh(),才能清除以前的高亮