Hi,
You are looking for the same ?
public override void OnMouseDown(int Button, int Shift, int X, int Y)
{
try
{
// TODO: Add SelectByShape.OnMouseDown implementation
IMxDocument pMxDoc = m_application.Document as IMxDocument;
IEnvelope pEnv;
IRubberBand pRubberBand;
IElement pElem;
//creat new rubber envople
pRubberBand = new RubberEnvelopeClass();
pEnv = pRubberBand.TrackNew(pMxDoc.ActiveView.ScreenDisplay, null) as IEnvelope;
//create new envolpe element
pElem = new RectangleElementClass();
pElem.Geometry = pEnv;
IFillShapeElement pFillShapeElement;
IFillSymbol pFillSymbol;
IColor pColor;
ILineSymbol pLineSymbol;
IGraphicsContainer pGContainer;
pFillShapeElement = pElem as IFillShapeElement;
//set fill symbol
pFillSymbol = pFillShapeElement.Symbol;
pColor = pFillSymbol.Color;
pColor.Transparency = 0;
pFillSymbol.Color = pColor;
//set the outline symbol;
pLineSymbol = pFillSymbol.Outline;
pColor.Transparency = 255;
pColor.RGB = 255;
pLineSymbol.Width = 12;
pFillSymbol.Outline = pLineSymbol;
//assing the symbol to teh rectangle
pFillShapeElement.Symbol = pFillSymbol;
//add rectange to the GC;
pGContainer = pMxDoc.ActiveView as IGraphicsContainer;
pGContainer.AddElement(pElem, 0);
pMxDoc.ActiveView.Refresh();
//use rectangle to search the top layer
ISpatialFilter pSpatialFilter = new SpatialFilterClass();
IFeatureCursor pFeatCursor;
IFeature pFeature;
IFeatureLayer pFeatLayer;
int intCount = 0;
pSpatialFilter.WhereClause = "FID >2";
pSpatialFilter.Geometry = pEnv;
pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
pFeatLayer = pMxDoc.SelectedLayer as IFeatureLayer;
pFeatCursor = pFeatLayer.Search(pSpatialFilter, false);
pFeature = pFeatCursor.NextFeature() as IFeature;
while(pFeature!=null)
{
intCount = intCount + 1;
pFeature = pFeatCursor.NextFeature();
}
MessageBox.Show("There are " + intCount + "Cities over 5000 Recangel Area");
pGContainer.DeleteAllElements();
}
catch (Exception exp) { }
}