Follow by Email

How to get a feature collection from current selection in MapInfo MapXtreme

If you are looking for answers to the below questions ?

How to get a feature collection from current selection in MapXtreme ?
How to get a feature collection using a select region tool in MapXtreme ?
How to get a feature collection of all the selected regions in MapXteme ?

If yes I have an answers for you,
1. First select a layer as Feature Layer, this layer will be the layer where you will be searching for the selected regions.
2. Now, Using Session.Current.Selection.DefaultSelection() pass the table of the currently selected layer as shown in the code below.
3. The above used method will return a IResultSetFeatureCollection irfc, here you will get a collection of all the selected region of that layer.
Below is the code that does the same.

C# code
FeatureLayer lyr=mapControl1.Map.Layers["layerNameToGoHere"] as FeatureLayer ;
IResultSetFeatureCollection irfc = Session.Current.Selections.DefaultSelection[lyr.Table ];
 
VB.NET Code
Dim lyr as FeatureLayer =mapControl1.Map.Layers["layerNameToGoHere"]
Dim irfc as IResultSetFeatureCollection = Session.Current.Selections.DefaultSelection

1 comments:

Aadi said...
This comment has been removed by the author.

Post a Comment