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


IMapControl2.AddShapeFile Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Controls > ESRI ArcGIS Controls > Interfaces > IM > IMapControl2 Interface > IMapControl2.AddShapeFile Method
ArcGIS Developer Help

IMapControl2.AddShapeFile Method

Adds a shapefile as a layer to the Map.

[Visual Basic .NET]
Public Sub AddShapeFile ( _
    ByVal Path As String, _
    ByVal fileName As String _
)
[C#]
public void AddShapeFile (
    string Path,
    string fileName
);
[C++]
HRESULT AddShapeFile(
  BSTR Path,
  BSTR fileName
);
[C++]
Parameters
Path [in]

Path is a parameter of type BSTR fileName [in]
fileName is a parameter of type BSTR

Product Availability

Available with ArcGIS Engine.

Description

When a shapefile is added to the MapControl's layer collection 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.

Errors Returned

1053 800a041d: The specified path is invalid
1054 800a041e: The specified filename is invalid

Remarks

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.

[C#]
//Add theRoads shapefile C:\arcgis\ArcTutor\Spatial\roads.shp
axMapControl1.AddShapeFile(@"D:\Temp", "roads.shp");/CODE>
[Visual Basic .NET]
'Add theRoads shapefile C:\arcgis\ArcTutor\Spatial\roads.shp
AxMapControl1.AddShapeFile("D:\Temp", "roads.shp")

See Also

IMapControl2 Interface | IMapControl4.AddLayer Method | IMapControl2.AddLayer Method | IMapControl3.AddLayer Method | IMapControl4.AddLayerFromFile Method | IMapControl2.AddLayerFromFile Method | IMapControl3.AddLayerFromFile Method

.NET Samples

Geoevents in a MapControl