Project.ProjectItems Propriedade
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Obtém uma ProjectItems coleção para o Project objeto.
public:
property EnvDTE::ProjectItems ^ ProjectItems { EnvDTE::ProjectItems ^ get(); };
[System.Runtime.InteropServices.DispId(202)]
public EnvDTE.ProjectItems ProjectItems { [System.Runtime.InteropServices.DispId(202)] get; }
[<System.Runtime.InteropServices.DispId(202)>]
[<get: System.Runtime.InteropServices.DispId(202)>]
member this.ProjectItems : EnvDTE.ProjectItems
Public ReadOnly Property ProjectItems As ProjectItems
Valor da propriedade
Uma coleção de ProjectItems.
- Atributos
Exemplos
Este exemplo funciona somente no Visual Studio .NET 2003 e versões posteriores. Para obter mais informações, consulte How to: programaticamente criar projetos.
Sub ProjectItemsExample(ByVal dte As DTE)
' NOTE: This example requires a reference to the
' VSLangProj namespace.
' Create a new solution.
Dim soln As Solution = dte.Solution
Dim solnName As String = "NewSolution.sln"
Dim tempPath As String = System.IO.Path.GetTempPath()
soln.Create(tempPath, solnName)
' Create a new Visual Basic Console Application project.
Dim templatePath As String =
dte.Solution.TemplatePath(PrjKind.prjKindVBProject)
templatePath &= "ConsoleApplication.vsz"
Dim projName As String = "NewProject"
soln.AddFromTemplate(templatePath, tempPath & projName, projName)
Dim proj As Project = soln.Item(1)
' Add a comment to Module1.vb.
Dim item As ProjectItem = proj.ProjectItems.Item("Module1.vb")
Dim sel As TextSelection = CType(item.Document.Selection,
TextSelection)
sel.StartOfDocument()
sel.NewLine()
sel.LineUp()
sel.Text = "' New comment" & vbCrLf
End Sub
public void ProjectItemsExample(DTE dte)
{
// NOTE: This example requires a reference to the
// VSLangProj namespace.
// Create a new solution.
Solution soln = dte.Solution;
string solnName = "NewSolution.sln";
string tempPath = System.IO.Path.GetTempPath();
soln.Create(tempPath, solnName);
// Create a new C# Console Application project.
string templatePath =
dte.Solution.get_TemplatePath(PrjKind.prjKindCSharpProject);
templatePath += "CSharpConsole.vsz";
string projName = "Project1";
soln.AddFromTemplate(templatePath, tempPath + projName,
projName, false);
Project proj = soln.Item(1);
// Add a comment to Class1.cs.
ProjectItem item = proj.ProjectItems.Item("Class1.cs");
TextSelection sel = (TextSelection)item.Document.Selection;
sel.StartOfDocument(false);
sel.NewLine(1);
sel.LineUp(false, 1);
sel.Text = "// New comment\n";
}
Comentários
A coleção retornada representa itens de projeto que podem estar hierarquicamente abaixo do item de projeto.