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


Display Template Information in MessageBox Snippet (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference

Display Template Information in MessageBox Snippet

Display path information on the loaded templates in a Message Box.

[C#]
///<summary>Display path information on the loaded templates in a Message Box.</summary>
///  
///<param name="application">An IApplication interface.</param>
///   
///<remarks></remarks>
public void DisplayTemplateInformationInMessageBox(ESRI.ArcGIS.Framework.IApplication application)
{
  ESRI.ArcGIS.Framework.ITemplates templates=application.Templates;

  //Active document path
  System.String documentFileName=templates.get_Item(templates.Count - 1);
  System.Windows.Forms.MessageBox.Show("Document path: " + documentFileName);

  //Templates
  for (System.Int32 i=0; i < templates.Count - 1; i++)
  {
    System.String templateName=(i == 0) ? "Normal template" : "Base template";
    System.Windows.Forms.MessageBox.Show(templateName + ": " + templates.get_Item(i));
  }
}
[Visual Basic .NET]
'''<summary>Display path information on the loaded templates in a Message Box.</summary>
'''  
'''<param name="application">An IApplication interface.</param>
'''   
'''<remarks></remarks>
Public Sub DisplayTemplateInformationInMessageBox(ByVal application As ESRI.ArcGIS.Framework.IApplication)

  Dim templates As ESRI.ArcGIS.Framework.ITemplates=application.Templates

  ' Active document path
  Dim documentFileName As System.String=templates.Item(templates.Count - 1)
  System.Windows.Forms.MessageBox.Show("Document path: " + documentFileName)

  ' Templates
  Dim i As System.Int32=0
  For i=0 To templates.Count - 1
    Dim templateName As System.String=CStr(Microsoft.VisualBasic.IIf((i=0), "Normal template", "Base template"))
    System.Windows.Forms.MessageBox.Show(templateName + ": " + templates.Item(i))
  Next i

End Sub

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Framework