Share via


Windows2.Item, méthode (Object)

Retourne un membre indexé d'une collection Windows.

Espace de noms :  EnvDTE80
Assembly :  EnvDTE80 (dans EnvDTE80.dll)

Syntaxe

'Déclaration
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

Paramètres

  • index
    Type : System.Object
    Obligatoire.L'index de l'élément à retourner.

Valeur de retour

Type : EnvDTE.Window
Objet Window.

Implémentations

Windows.Item(Object)

Notes

La valeur passée à Index est un entier qui représente l'index d'un objet de sa collection. Néanmoins, pour de nombreux objets, la valeur d'Index peut également être une valeur de chaîne qui équivaut à un objet dans la collection. La valeur exacte acceptée par Item dépend cependant de la collection et de son implémentation.

La méthode Item lève une exception ArgumentException si la collection ne peut pas trouver l'objet correspondant à la valeur d'index.

Exemples

Cet exemple affiche la légende de tous les éléments de la collection Windows2.

Pour plus d'informations sur l'exécution de cet exemple comme complément, consultez Comment : compiler et exécuter les exemples de code du modèle objet Automation.

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);
}

Sécurité .NET Framework

Voir aussi

Référence

Windows2 Interface

Item, surcharge

EnvDTE80, espace de noms

Autres ressources

Comment : compiler et exécuter les exemples de code du modèle objet Automation