Share via


SelectedItems.Count Property

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

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
ReadOnly Property Count As Integer
'Usage
Dim instance As SelectedItems 
Dim value As Integer 

value = instance.Count
int Count { get; }
property int Count {
    int get ();
}
function get Count () : int

Property Value

Type: System.Int32
An integer value representing the number of objects in the SelectedItems collection.

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

.NET Framework Security

See Also

Reference

SelectedItems Interface

SelectedItems Members

EnvDTE Namespace

Other Resources

How to: Compile and Run the Automation Object Model Code Examples