Hi I have the following code below for zooming into an arcGIS object based on the attribute now all I need is to be able to highlight that area with a select feature (The feature where you right-click on the area on the map and do select feature).
Currently I have an event which will do the zoom.I want to add this select to the same attribute as well.
Thank you in advance!!!
ESRI.ArcGIS.Carto.ILayer layer = GetLayersClass.GetFieldBoundaryLayer;
if (layer is ESRI.ArcGIS.Carto.IGroupLayer)
{
ESRI.ArcGIS.Carto.IGroupLayer groupLayer = layer as ESRI.ArcGIS.Carto.IGroupLayer;
ICompositeLayer pCompositeLayer = layer as ICompositeLayer;
int layers = pCompositeLayer.Count;
ILayer pLayer = pCompositeLayer.Layer[0];
IFeatureLayer pFeatureLayer = (IFeatureLayer)pLayer;
IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
IQueryFilter pFilter = new QueryFilterClass();
pFilter.WhereClause = "RightID = '" + selectedRightID.ToString() + "'";
IFeatureCursor pFeatureCursor = pFeatureClass.Search(pFilter, false);
IFeature pFeature = pFeatureCursor.NextFeature();
if (pFeature == null)
{
System.Windows.Forms.MessageBox.Show("This section doesn't exist");
return;
}
IApplication m_application = ArcMap.Application;
IMxDocument pMxDoc = (IMxDocument)m_application.Document;
IActiveView pActiveView = (IActiveView)pMxDoc.FocusMap;
IEnvelope pEnv = pFeature.Shape.Envelope;
pEnv.Expand(1.1, 1.1, true);
pActiveView.Extent = pEnv;
pActiveView.Refresh();
I tried by adding this code which I think will add the particular feature to the selection. but no luck with that as well.
IFeatureSelection pfeatSelect = pFeatureLayer as IFeatureSelection;
pfeatSelect.Add(pFeature);
If I understand you correctly, all you need is this:
IFeatureSelection featSelect = pFeatureLayer as IFeatureSelection;
featSelect.SelectFeatures(pFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
This will select all Features that match your filter.