This project is read-only.

Highlight Features using IndexSelection

Jul 17, 2014 at 8:05 AM
Have this bit of code which works fine if PolygonLayer property has a FeatureSelection as Selection. but does not highlight the features on the map when Selection property is of type IndexSelection.

What am I doing wrong?
Thanks
public void HighlightFeature(IFeature feature)
        {
            if (_ignoreSelectionChanged) return;
            _ignoreSelectionChanged = true;

            if (FeatureSet.AttributesPopulated)
            {
                //manage selection using the Selection property
                FeatureSelection sel = PolygonLayer.Selection as FeatureSelection;
                if (sel != null)
                {
                    sel.Clear();
                    sel.Add(feature);
                }
                else if (PolygonLayer.Selection is IndexSelection)
                {
                    IndexSelection isel = PolygonLayer.Selection as IndexSelection;
                    isel.Clear();
                    isel.Add(feature.Fid);
                }
                else
                {
                    PolygonLayer.Select(feature.Fid);
                }

                if (PolygonLayer != null)
                {
                    PolygonLayer.Invalidate();
                }
                _ignoreSelectionChanged = false;
            }
        }
Jul 24, 2014 at 1:41 AM
Found out the layer was in EditMode. This stops features being highlighted.

so for me, I did the equivalent of PolygonLayer.EditMode = false;
Marked as answer by ahrensd on 7/23/2014 at 5:41 PM