Documents.Item(Object) Yöntem

Tanım

Bir koleksiyonun dizinli bir üyesini döndürür Documents .

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

Parametreler

index
Object

Gereklidir. Döndürülecek öğenin dizini.

Döndürülenler

Document

Bir Document nesnesi.

Öznitelikler

Örnekler

Sub ItemExample(ByVal dte As DTE2)  

    ' NOTE: This example requires a reference to the   
    '       System.Collections namespace.  

    If MsgBox("Close all saved documents?", MsgBoxStyle.YesNo) = _  
        MsgBoxResult.Yes Then  
        ' Create a list of all saved documents.  
        Dim docs As Documents = dte.Documents  
        Dim savedDocs As New ArrayList  

        Dim i As Integer  
        For i = 1 To docs.Count  
            If docs.Item(i).Saved Then  
                savedDocs.Add(docs.Item(i))  
            End If  
        Next  

        ' Close all saved documents.  
        Dim doc As Document  
        For Each doc In savedDocs  
            doc.Close(vsSaveChanges.vsSaveChangesNo)  
        Next  
    End If  

End Sub  
public void ItemExample(DTE2 dte)  
{  
    // NOTE: This example requires a reference to the   
    //       System.Collections namespace.  

    if (MessageBox.Show("Close all saved documents?", "",   
        MessageBoxButtons.YesNo) == DialogResult.Yes)  
    {  
        // Create a list of all saved documents.  
        Documents docs = dte.Documents;  
        ArrayList savedDocs = new ArrayList();   

        for (int i = 1; i <= docs.Count; i++)  
        {  
            if (docs.Item(i).Saved)  
                savedDocs.Add(docs.Item(i));  
        }  

        // Close all saved documents.  
        foreach (Document doc in savedDocs)  
            doc.Close(vsSaveChanges.vsSaveChangesNo);  
    }  
}  

Açıklamalar

Çoğu nesne için, öğesine geçirilen değer Index koleksiyonundaki bir nesne için dizin olan bir tamsayıdır. Ancak, çoğu nesne için, değeri koleksiyondaki bir Index nesneye karşılık gelen bir dize değeri de olabilir. Tarafından kabul edilen tam değer, Item koleksiyona ve uygulamasına bağlıdır.

Item ArgumentException Koleksiyon, dizin değerine karşılık gelen nesneyi bulamazsa Yöntem bir özel durum oluşturur.

Şunlara uygulanır