Aracılığıyla paylaş


Documents.Item Yöntem

Dizinlenmiş bir üye döndüren bir Documents koleksiyonu.

Ad alanı:  EnvDTE
Derleme:  EnvDTE (EnvDTE.dll içinde)

Sözdizimi

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

Parametreler

  • index
    Tür: System.Object
    Gerekli.Geri dönmek için öğenin dizini.

Dönüş Değeri

Tür: EnvDTE.Document
Document nesnesi

Notlar

Çoğu nesneler için değer geçirilen Index bir nesneyi kendi koleksiyonundaki dizin olan bir tamsayıdır.Çoğu nesneler için yine de değeri Index koleksiyondaki nesneye eşit olur bir dize değeri de olabilir.Tam değer olarak kabul edilen Item, yine de toplama ve bunun uygulanmasının bağlıdır.

Item Yöntemi throws bir ArgumentException koleksiyonu endeks değerine karşılık gelen nesne bulamazsa, özel durum.

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

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

Documents Arabirim

EnvDTE Ad Alanı

Diğer Kaynaklar

Nasıl yapılır: derlemek ve Otomasyon nesne modeli kod örneklerini çalıştırmak