Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have 2 ESRI feature layers on my map; points and polylines. I can select them just fine either by rectangle or polygon. What I am missing is how to highlight (larger size and different color) the selected points and polylines for display. Do I need to create new layers with just the selected features and use a renderer or place a graphic container on the map with those features highlighted? The ultimate goal is to have the selected and highlighted features available for deletion.

Using ArcEngine and ArcSDE. C# .NET.

Thank you.

share|improve this question
add comment

2 Answers

Are you just looking for selection code? (Don't really understand what you are requesting?!) This code will highlight (as an outline) your selection on the target layer using a filter clause ("Key = whatever") in accordance with the passed esriSelectionResultEnum flag:

public static void SelectBy(
    IActiveView view, 
    ILayer2 targetLayer, 
    string filterClause, 
    esriSelectionResultEnum selectionResult
)
{
    IFeatureSelection featureSelection = targetLayer as IFeatureSelection;
    if (featureSelection == null) return;
    IQueryFilter queryFilter = new QueryFilterClass();
    queryFilter.WhereClause = filterClause;
    IColor selectColor = Local.ColorToIColor(System.Drawing.Color.OrangeRed);
    ISimpleFillSymbol fillSymbol = new SimpleFillSymbolClass();
    fillSymbol.Color = selectColor;
    ISimpleLineSymbol outlineSymbol = new SimpleLineSymbolClass();
    outlineSymbol.Color = selectColor;
    outlineSymbol.Width = 2;
    fillSymbol.Outline = outlineSymbol;
    fillSymbol.Style = esriSimpleFillStyle.esriSFSHollow;
    featureSelection.SelectionSymbol = fillSymbol as ISymbol;
    featureSelection.SetSelectionSymbol = true;
    featureSelection.SelectFeatures(queryFilter, selectionResult, false);
    view.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, view.FocusMap, null);
}

If you know the data this will work. If you need to select by shape that is different.

share|improve this answer
    
Thanks, this is just what I needed. Made a few modifications and it did what I wanted. –  Milton Mar 12 '12 at 0:53
add comment

There are a couple of ways to do this:

  1. Select your features and create a new layer. Then you can do whatever you want with them while still keeping the original data. If you want to delete those features at a later time, you can do that too.

  2. Create a new field in the attributes of the layers. Something like "SELECT" or whatever makes it clear. Then select your features and use the field calculator to add an indicator (like "YES") to the selected features "SELECT" field. You can now use a definition querry to isolate those features. It will be something like: display only features where [SELECT] = "YES". To get all features on the map, just copy and paste the layer so there is one with the D.Q. and one without.

Hope this helps.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.