ArcObjects Library Reference (Controls)  

IMapControl4.LoadMxFile Method

Loads the specified Map from the map document into the MapControl. The Map can be an index or a name, if it is not supplied the focus map is used.

[Visual Basic .NET]
Public Sub LoadMxFile ( _
    ByVal mxPath As String, _
    [ByVal mapNameOrIndex As Object], _
    [ByVal password As Object] _
)
[C#]
public void LoadMxFile (
    string mxPath,
    object mapNameOrIndex,
    object password
);
[C#]

Optional Values

mapNameOrIndex   To indicate that this parameter is undefined, pass in Type.Missing.
password   To indicate that this parameter is undefined, pass in Type.Missing.
[C++]
HRESULT LoadMxFile(
  BSTR mxPath,
  VARIANT mapNameOrIndex,
  VARIANT password
);
[C++]

Parameters

mxPath [in]   mxPath is a parameter of type BSTR mapNameOrIndex [optional]   mapNameOrIndex is a parameter of type VARIANT

  To indicate this parameter is undefined pass in a VARIANT with type VT_ERROR and scode value of DISP_E_PARAMNOTFOUND.

password [optional]   password is a parameter of type VARIANT

  To indicate this parameter is undefined pass in a VARIANT with type VT_ERROR and scode value of DISP_E_PARAMNOTFOUND.

Product Availability

Available with ArcGIS Engine.

Description

Loads an map Document into the MapControl. The map document can be an ArcMap document, an ArcMap template or an ArcReader document. Use the CheckMxFile method to determine  if the specified map document is a valid map document.

Remarks

When LoadMXfile is used the user may be prompted for a password; refer to the tables below to determine when this may occur. Additionally, password prompts may be given if accessing MapDocuments using either the MapControl's PropertyPage, ArcMap or ArcReader; the tables also show in what circumstances this will occur.

Loading Map Documents (*.mxd, *.mxt, *.pmf) which reference IMS Services (with and without security)

Application No Secure Services MXD/ MXT/ PMF files Secure Servcies MXD/ MXT/ PMF files Secure Servcies (password cached) MXD/ MXT files Secure Servcies (password cached) PMF files
MapControl (programmatically) No Prompt Prompt No Prompt Prompt
MapControl (property pages) No Prompt Prompt No Prompt Prompt
ArcMap No Prompt Prompt No Prompt Prompt
ArcReader (PMF files only) No Prompt Prompt N/A No Prompt

* The Connection to the Internet server must have the Save User/ Password setting enabled. This can be set, for example, when using Add Internet Server in the Add Layers Dialog. Additionally, in the case of PMF files the ArcPublisher Cache password in PMF file setting must be enabled.

Loading Published Map Files (*.pmf) (with and without password protection)

Application PMF with No Password PMF with Password
MapControl (programmatically) No Prompt Supply in Code
MapControl (property pages) No Prompt Prompt
ArcMap No Prompt Prompt
ArcReader No Prompt Prompt

See Also

IMapControl4 Interface | IMapControl2.CheckMxFile Method | IMapControl4.CheckMxFile Method | IMapControl3.CheckMxFile Method | IMapControl3.ReadMxMaps Method | IMapControl4.ReadMxMaps Method | IMapControl2.ReadMxMaps Method