次の方法で共有


Document.Close メソッド

開いているドキュメントを閉じ、オプションでドキュメントを保存します。またはウィンドウを閉じ、破棄します。

名前空間:  EnvDTE
アセンブリ:  EnvDTE (EnvDTE.dll 内)

構文

'宣言
Sub Close ( _
    Save As vsSaveChanges _
)
void Close(
    vsSaveChanges Save
)
void Close(
    [InAttribute] vsSaveChanges Save
)
abstract Close : 
        Save:vsSaveChanges -> unit 
function Close(
    Save : vsSaveChanges
)

パラメーター

Sub CloseExample(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 CloseExample(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 セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

Document インターフェイス

EnvDTE 名前空間

その他の技術情報

方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する