Compartilhar via


Como: Iniciar arquivos específicos quando abrir os modelos

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.

ObservaçãoObservação

If you are modifying an existing template, see Como: Atualizar modelos existentes 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

  1. Locate the ProjectItem element in the .vstemplate file that includes the file you want opened.

  2. 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

  1. Locate the ProjectItem elements in the .vstemplate file that include the files you want opened.

  2. Set the OpenInEditor attribute to true for each element.

  3. 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>
    
    ObservaçãoObservação

    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

  1. Locate the ProjectItem element that includes your documentation file in the template.

  2. 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

  1. Locate the ProjectItem element in the .vstemplate file that includes the file you want opened.

  2. Set the OpenInHelpBrowser attribute to true for that element. For example:

    <ProjectItem OpenInHelpBrowser="true">Doc.html</ProjectItem>
    

Consulte também

Referência

Referência de esquema de modelo do Studio Visual

Elemento ProjectItem (modelos de Item Visual Studio)

Elemento ProjectItem (modelos de projeto Visual Studio)

Outros recursos

Starter Kits

Modelos Visual Studio