pFeatureLayer = this.axMapControl1.Map.get_Layer(0) as IFeatureLayer;
if (pFeatureLayer.Name != "parcel")
pQueryFilter = new QueryFilterClass();
pQueryFilter.WhereClause = "cc_number='LEKMA'";
pFeatureCursor = pFeatureLayer.Search(pQueryFilter, true);
pFeature = pFeatureCursor.NextFeature();
IFeatureSelection featureSelection = pFeature as IFeatureSelection;
if (pFeature != null)
this.axMapControl1.Extent = pFeature.Shape.Envelope;
MessageBox.Show("Not found" + "LEKMA");
At first you can't cast from IFeature to IFeatureSelection. You can cast IFeatureLayer to IFeatureSelection.
So it would be:
IFeatureSelection featureSelection = pFeatureLayer as IFeatureSelection;
If you look at your layer Properties-Selection tab you will find options on showing selection:
The first one is ArcMap setting which changes all layers selection showing. I think you don't want to change all layers selection to red. If you do then you should use SelectionColor on IMapDescription2.
If you are interesting in third option then you should use SelectionColor on ILayerDescription.
More info about both cases here:
If you want mark one special from selection you can use IGraphicsContainer to draw graphic element on top of your feature with color or shape you want.