参照下面代码,希望对你有帮助
IQueryFilter filter = new QueryFilterClass();
filter.WhereClause = " NAME='"+城市名称+"'";
IFeatrueSel.SelectFeatures(filter, esriSelectionResultEnum.esriSelectionResultNew, false);
IFeatureCursor cursor = IFeatureLay.Search(filter, false);
IFeature feat = cursor.NextFeature();
if (feat != null)
{
//先清除地图中被选中的要素
this.axMapControl1.Map.ClearSelection();
IGeometry zdGeo = feat.Shape;
try
{
this.axMapControl1.ActiveView.ExtentStack.Do(zdGeo.Envelope);
this.axMapControl1.ActiveView.Extent = zdGeo.Envelope;
this.axMapControl1.ActiveView.Refresh();
this.axMapControl1.FlashShape(zdGeo, 2, 300, Type.Missing);
}
catch (Exception ex)
{
return;
}
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);