Compartilhar via


Windows2.Item Method

Returns an indexed member of a Windows collection.

Namespace:  EnvDTE80
Assembly:  EnvDTE80 (in EnvDTE80.dll)

Syntax

'Declaration
Function Item ( _
    index As Object _
) As Window
Window Item(
    Object index
)
Window^ Item(
    [InAttribute] Object^ index
)
abstract Item : 
        index:Object -> Window
function Item(
    index : Object
) : Window

Parameters

  • index
    Type: Object

    Required. The index of the item to return.

Return Value

Type: EnvDTE.Window
A Window object.

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.

Examples

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

For more information about how to run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples.

Imports EnvDTE
Imports EnvDTE80
Public Sub OnConnection(ByVal application As Object, _
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    IterateItems(_applicationObject)
End Sub
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 OnConnection(object application, 
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    IterateItems(_applicationObject);
}
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);
}

.NET Framework Security

See Also

Reference

Windows2 Interface

EnvDTE80 Namespace

Other Resources

How to: Compile and Run the Automation Object Model Code Examples