共用方式為


SelectionContainer.Count 屬性

取得值,指出集合中物件的數目。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
ReadOnly Property Count As Integer
int Count { get; }
property int Count {
    int get ();
}
abstract Count : int with get
function get Count () : int

屬性值

類型:Int32
整數。

範例

Public Sub CodeExample(ByVal dte As DTE2) 
    Try
        ' Open a project and select some items in 
        ' Solution Explorer before running this example.
        Dim selCon As SelectionContainer = dte.SelectedItems.SelectionContainer
        Dim msg As String = "Container has items: " + selCon.Count.ToString()
        If selCon.Parent Is dte.SelectedItems Then
            msg += vbCrLf + "The SelectionContainer has a SelectedItems as a parent object."
        End If
        msg += vbCrLf + "This SelectionContainer is in this application: " + selCon.DTE.Name
        
        MessageBox.Show(msg)
    
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub
public void CodeExample(DTE2 dte)
{  
    try
    {   // Open a project and select some items in 
        // Solution Explorer before running this example.
        SelectionContainer selCon= dte.SelectedItems.SelectionContainer;
        string msg = "Container has items: " + selCon.Count.ToString();
        if (selCon.Parent.Equals(dte.SelectedItems))
            msg += "\nThe SelectionContainer has a SelectedItems as a parent object.";
        msg += "\nThis SelectionContainer is in this application: " + selCon.DTE.Name;

        MessageBox.Show(msg);

    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 安全性

請參閱

參考

SelectionContainer 介面

EnvDTE 命名空間

其他資源

如何:編譯和執行 Automation 物件模型程式碼範例