This document is archived and information here might be outdated. Recommended version. |
ArcObjects namespaces > Controls > ESRI ArcGIS Controls > Interfaces > IM > IMapControl4 Interface > IMapControl4.AddLayer Method (ArcObjects .NET 10.4 SDK) |
Adds a layer to the Map's collection of layers at the specified index position.
[Visual Basic .NET] Public Sub AddLayer ( _ ByVal Layer As ILayer, _ [ByVal toIndex As Integer] _ )
[C#] public void AddLayer ( ILayer Layer, int toIndex );
Optional Values
[C++]
HRESULT AddLayer(
ILayer* Layer,
long toIndex
);
[C++]
Parameters Layer [in]
Layer is a parameter of type ILayer toIndex [in, optional, defaultvalue(0)] toIndex is a parameter of type long
When a Layer is added to the MapControl's layer collection and no index is specified, it is added to the beginning or top of the collection with an index of 0. The numeric index of any other layers in the layer collection increments by one.
When a Layer is added and an index is specified, the numeric index of any other layers in the layer collection will increment by one, except for those layers with an index less than the specified index. The index of these layers will remain the same.
1023 800a03ff: The specified index is out of range
The Layer at the beginning or top of the collection with an index of 0 will be drawn last, whilst the Layer at the bottom of the collection will be drawn first.
Use the MoveLayerTo method to change the position of a Layer within the layer collection.
IMapControl4 Interface | IMapControl4.AddLayerFromFile Method | IMapControl2.AddLayerFromFile Method | IMapControl3.AddLayerFromFile Method | IMapControl3.AddShapeFile Method | IMapControl2.AddShapeFile Method | IMapControl4.AddShapeFile Method