Condividi tramite


Windows2.Item(Object) Method

Definition

Returns an indexed member of a Windows collection.

public:
 EnvDTE::Window ^ Item(System::Object ^ index);
public:
 EnvDTE::Window ^ Item(Platform::Object ^ index);
EnvDTE::Window Item(winrt::Windows::Foundation::IInspectable const & index);
[System.Runtime.InteropServices.DispId(0)]
public EnvDTE.Window Item (object index);
[<System.Runtime.InteropServices.DispId(0)>]
abstract member Item : obj -> EnvDTE.Window
Public Function Item (index As Object) As Window

Parameters

index
Object

Required. The index of the item to return.

Returns

A Window object.

Implements

Attributes

Examples

This example displays the caption of all the items in the Windows2 collection.

Imports EnvDTE  
Imports EnvDTE80  
Sub IterateItems(ByVal dte As DTE2)  
    Dim win As Windows2  
    win = CType(_applicationObject.Windows, EnvDTE80.Windows2)  
    Dim aString As String  
    aString = ""  
    Dim count As Integer  
    count = win.Count  
    Dim i As Integer  
    For i = 1 To count Step 1  
        aString = aString & "The window number " & i & _  
 " in the collection, has the caption: " & win.Item(i).Caption & vbCr  
    Next  
    MsgBox(aString)  
End Sub  
using EnvDTE;  
using EnvDTE80;  
using System.Windows.Forms;  
public void IterateItems(DTE2 dte)  
{  
    Windows2 win;  
    win = (EnvDTE80.Windows2)_applicationObject.Windows;  
    int count = win.Count;  
    String aString = null;  
    for (int i = 1; i <= count; i++ )  
    {  
        aString = aString + ("The window number " + i +   
" in the collection, has the caption: " + win.Item(i).Caption + "\n");  
    }  
    MessageBox.Show(aString);  
}  

Remarks

The value passed to Index is an integer that is an index to an object in its collection. For many objects, though, the value of Index can also be a string value that equates to an object in the collection. The exact value that is accepted by Item, though, depends upon the collection and its implementation.

The Item method throws a ArgumentException exception if the collection cannot find the object that corresponds to the index value.

Applies to