SelectedItems.Count Property

Definition

Gets a value indicating the number of objects in the SelectedItems collection.

public:
 property int Count { int get(); };
public:
 property int Count { int get(); };
[System.Runtime.InteropServices.DispId(1)]
public int Count { [System.Runtime.InteropServices.DispId(1)] get; }
[<System.Runtime.InteropServices.DispId(1)>]
[<get: System.Runtime.InteropServices.DispId(1)>]
member this.Count : int
Public ReadOnly Property Count As Integer

Property Value

An integer value representing the number of objects in the SelectedItems collection.

Attributes

Examples

public void CodeExample(DTE2 dte)  
{    
    try  
    {  
        // Open project and select one or more items in the  
        // solution explorer before running this example.  
        SelectedItem selItem;  
        string msg = "";  
        if (dte.SelectedItems.Count > 0)  
        {  
            selItem = dte.SelectedItems.Item(1);  
            msg = "The first selected item is " + selItem.Name;  
        }  
        MessageBox.Show(msg);  
    }  
    catch(Exception ex)  
    {  
        MessageBox.Show(ex.Message);  
    }  
}  

Applies to