Select to view content in your preferred language

Attribute Editing for multiple layers

1226
13
10-29-2010 06:23 AM
WilliamDonahue
Emerging Contributor
I was wondering if it was possible to use one attribute editor for multuiple layers. It would streamline my application stream and reduce the file size.
0 Kudos
13 Replies
AliMirzabeigi
Emerging Contributor
Map doesn't have the Graphics attribute, and the following line fails in yourFeatureLayer_MouseLeftButtonUp event handler:
foreach (Graphic item in Map.Graphics)
     item.Selected = false;
Instead you should get the feature layer firing the event and loop through the collection of graphics in that layer, i.e.
FeatureLayer layer = sender as FeatureLayer;
foreach (Graphic item in layer.Graphics)
     item.Selected = false;
this.Attributes.FeatureLayer = layer;
// And the rest of your code
........
0 Kudos
WilliamDonahue
Emerging Contributor
Ali

The code you provided appears clear the layer that was currently selected. My app has 3 total featrue layers and what i want to do is clear all the selections from all the layers before the new selection is made. the rest of my code should make the new selection.

Thanks,

Will
0 Kudos
AliMirzabeigi
Emerging Contributor
In that case in you can do something similar to the following in the MouseLeftButtonUp event handler (before the line "FeatureLayer layer = sender as FeatureLayer;") to clear selection from all "FeatureLayer" layers of your map control:
foreach (Layer layer in MyMap.Layers)
            {
                if (layer is FeatureLayer)
                {
                    foreach (Graphic item in (layer as FeatureLayer).Graphics)
                        item.Selected = false;
                }
            }
0 Kudos
WilliamDonahue
Emerging Contributor
Thanks Guys for all the help. That worked.
0 Kudos