How to: Launch Specific Files When Opening Templates
When you open a project template in the development environment, you may also want to display a specific source file. For example, when you create a Windows application, you might want to display a blank form or the default Windows form as a starting point for development.
A file can be opened in the following ways:
The source code of a file can be opened in the code editor.
The file can be opened in the Web browser.
The file can be opened in the Help viewer.
Note
If you are modifying an existing template, see How to: Update Existing Templates for more information.
Opening a Source Code File for Editing
Use this procedure to open a source code file when a user creates a new project with the template.
To open a source code file for editing
Locate the ProjectItem element in the .vstemplate file that includes the file you want opened.
Set the OpenInEditor attribute to true for that element. For example:
<ProjectItem OpenInEditor="true">Class1.vb</ProjectItem>
You can also specify multiple files, as well as the order in which they will open.
To open multiple source code files for editing
Locate the ProjectItem elements in the .vstemplate file that include the files you want opened.
Set the OpenInEditor attribute to true for each element.
Assign a value to the OpenOrder attribute for each element. For example:
<ProjectItem OpenInEditor="true" OpenOrder="10"> Class1.vb </ProjectItem> <ProjectItem OpenInEditor="true" OpenOrder="20"> Class2.vb </ProjectItem>
Note
Set the OpenOrder value in multiples of ten. In this example, Class1.vb opens first, followed by Class2.vb.
Opening a File in a Web Browser
Use this procedure to open a file in the Web browser when a project is created based on the template.
To open documentation when a template is loaded
Locate the ProjectItem element that includes your documentation file in the template.
Set the OpenInWebBrowser attribute to true on the ProjectItem element. For example:
<ProjectItem OpenInWebBrowser="true">Documentation.htm</ProjectItem>
Opening a File in the Help Viewer
You can use the OpenInHelpBrowser attribute to open files in the Help viewer.
To open a file in the Help viewer
Locate the ProjectItem element in the .vstemplate file that includes the file you want opened.
Set the OpenInHelpBrowser attribute to true for that element. For example:
<ProjectItem OpenInHelpBrowser="true">Doc.html</ProjectItem>
See Also
Reference
Visual Studio Template Schema Reference
ProjectItem Element (Visual Studio Item Templates)
ProjectItem Element (Visual Studio Project Templates)