Make a new selection from an existing selection

502
7
06-14-2012 03:24 AM
AysberqTundra
Occasional Contributor
Hello.

I want to make a new selection from an existing selection, keep the old selection and change the highlight color of the new selection.
Can you give me any idea?

Thanks.
0 Kudos
7 Replies
DuncanHornby
MVP Notable Contributor
Unless I'm wrong I've always understood that a FeatureLayer can only have 1 selection, therefore what you are asking is not possible.

An off the top of my head idea is:

You could try creating a field and update that to indicate the first selection. Create a second field and update that with your second selection. Combine the values into these 2 fields into a third field and symbolize based upon the third field?

Duncan
0 Kudos
MauriceSchoenert
New Contributor
this will add the new selection to the old, dont know about the color:

pFeatureSelection.SelectFeatures pQueryFilter, esriSelectionResultAdd, False
0 Kudos
AysberqTundra
Occasional Contributor
Thanks for all replies.

But when I select a row (from selected rows) in attribute table of ArcMap, ArcMap highlights the feature on map.
I want to do the same.
If ArcMap has this functionality, I think it must be possible for custom application too. Am I wrong?
0 Kudos
JoeHershman
MVP Regular Contributor
Thanks for all replies.

But when I select a row (from selected rows) in attribute table of ArcMap, ArcMap highlights the feature on map.
I want to do the same.
If ArcMap has this functionality, I think it must be possible for custom application too. Am I wrong?


The behavior you mention in your second post differs from what you are asking in your initial post.  The behavior you describe above is simply ArcMap highlighting a feature you selected, this differs from having two distinct selection sets which is what your initial post seems to be asking about.

What is happening in the case above is basically a highlight graphic is being drawn with the same shape as the feature.  This is certainly something that could be done.  You could keep you selection and sub-selection set as collections withing your application and draw your own graphics using the shape of the features and these graphics could differ.  To me this seems like it would accomplish your goal, it is different though from having two SelectionSets for the same FeatureLayer

Good Luck
Thanks,
-Joe
0 Kudos
AysberqTundra
Occasional Contributor
Thanks for your reply, Joe.

But in ArcMap this functionality has been provided not using graphics. It is something other. Can you give me any other idea?
0 Kudos
JoeHershman
MVP Regular Contributor
Not sure why you are so sure that it is not Graphics (i.e., Elements).  There is nothing special about that 'Sub-Selection' other than its color.  A SelectionSet is nothing more than a collections of Features which you have the ability to query and are drawn in a different color on the screen.  You could just as easily create your own collection of Features

   List<IFeature> subSelection = new List<IFeature>();



and draw these Features as IElements (setting Locked=true so the user cannot modify them) in a color that signifies what they are.  Using Linq you could even make you own class that inherits for List<IFeature> and give it similar query abilities to what the SelectionSet provides.  I am just not sure I understand what you think is so special about the Features that ArcMap highlights in the situation you describe and why just using your own collection and highlighting them yourself does not accomplish the goal you are trying to achieve.

Good Luck
Thanks,
-Joe
0 Kudos
AysberqTundra
Occasional Contributor
Not sure why you are so sure that it is not Graphics (i.e., Elements).  There is nothing special about that 'Sub-Selection' other than its color.  A SelectionSet is nothing more than a collections of Features which you have the ability to query and are drawn in a different color on the screen.  You could just as easily create your own collection of Features

   List<IFeature> subSelection = new List<IFeature>();



and draw these Features as IElements (setting Locked=true so the user cannot modify them) in a color that signifies what they are.  Using Linq you could even make you own class that inherits for List<IFeature> and give it similar query abilities to what the SelectionSet provides.  I am just not sure I understand what you think is so special about the Features that ArcMap highlights in the situation you describe and why just using your own collection and highlighting them yourself does not accomplish the goal you are trying to achieve.

Good Luck



I am sure, because when I add custom graphics I can select it with graphics select tool, but when I do this process using ArcMap attribute table I can't select any object with graphics select tool.
0 Kudos