This document is archived and information here might be outdated.  Recommended version.


IFeatureLayerDefinition.CreateSelectionLayer Method (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference (Carto)  

IFeatureLayerDefinition.CreateSelectionLayer Method

Creates a new feature layer from the existing layer based on the current selection and the specified query expression.

[Visual Basic .NET]
Public Function CreateSelectionLayer ( _
    ByVal LayerName As String, _
    ByVal useCurrentSelection As Boolean, _
    ByVal joinTableNames As String, _
    ByVal Expression As String _
) As IFeatureLayer
[C#]
public IFeatureLayer CreateSelectionLayer (
    string LayerName,
    bool useCurrentSelection,
    string joinTableNames,
    string Expression
);
[C++]
HRESULT CreateSelectionLayer(
  BSTR LayerName,
  VARIANT_BOOL useCurrentSelection,
  BSTR joinTableNames,
  BSTR Expression,
  IFeatureLayer** Layer
);
[C++]

Parameters LayerName [in] LayerName is a parameter of type BSTR useCurrentSelection [in] useCurrentSelection is a parameter of type VARIANT_BOOL joinTableNames [in] joinTableNames is a parameter of type BSTR Expression [in] Expression is a parameter of type BSTR Layer [out, retval]
Layer is a parameter of type IFeatureLayer

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

CreateSelectionLayer creates a new FeatureLayer from an existing FeatureLayer.
LayerName defines the new layer's name.
Set useCurrentSelection=TRUE here if you want to use the currently selected features on the existing layer.
joinTableNames may contain the name of related table(s) separated by commas. The existing join(s) will then be passed on to the new layer.
The DefinitionExpression parameter can be used to set a definition expression on the newly created layer but currently this will be defined at the feature class rather than at the layer level and will not show up in the UI. If you want to set a definition query on the newly created layer, it is best to use IFeatureLayerDefinition again to set the definition query after the layer has been created.

See Also

IFeatureLayerDefinition Interface