Export (0) Print
Expand All
Expand Minimize

Items Property

Visual Studio .NET 2003

Returns the collection of files and top-level folders in a project or the collection of files and folders in a folder.

[Visual Basic .NET]
Public ReadOnly Property Items() As Object
[Visual Basic 6]
Property Get Items() As Object
[C++]
HRESULT __stdcall get_Items(
   /* [out, retval] */ IDispatch** retVal
);
[C#]
public object Items {get;}
[JScript .NET]
public function get Items() : Object

Example

For the VCFile object, returns the files associated with the selected file.

Example

The following sample code uses Items property in the development environment:

' add reference to Microsoft.VisualStudio.VCProjectEngine
Imports EnvDTE
Imports Microsoft.VisualStudio.VCProjectEngine

Public Module Module1
    Sub Main()
        Dim idx, idx2 As Integer
        Dim prj As VCProject
        Dim mycollection As IVCCollection

        Dim myfile As VCFile
        Dim myfilter, myfilter2 As VCFilter
        Dim myitem, myitem2 As VCProjectItem
        Dim mycoll2 As IVCCollection

        prj = DTE.Solution.Projects.Item(1).Object
        mycollection = prj.Items

        ' mycollection.Count has number of items

        For idx = 1 To mycollection.Count
            myitem = mycollection.Item(idx)
            If myitem.Kind = "VCFile" Then
                myfile = myitem
                ' myfile.Name has name of file
            Else
                myfilter = myitem
                ' myfilter.Name has name of folder
                ' inner loop shows how to look at the members of a folder
                mycoll2 = myfilter.Items
                For idx2 = 1 To mycoll2.Count
                    myitem2 = mycoll2.Item(idx2)
                    If myitem2.Kind = "VCFilter" Then
                        myfilter2 = myitem2
                        ' myfilter2.Name has name of nested folder
                    Else
                        myfile = myitem2
                        ' myfile.Name has name of nested file
                    End If
                Next
            End If
        Next
    End Sub
End Module

See Samples for Project Model Extensibility for information on how to compile and run this sample.

See Also

Applies To: VCFile Object | VCFilter Object | VCProject Object

Show:
© 2014 Microsoft