Use the SelectedIndex property to determine the index of the currently selected item in a ListView control. You can also use this property to programmatically select an item in the control. (However, if you manually data-bind the ListView control, you might have to handle reading or setting this property manually as well.)
The following example shows how to use the SelectedIndex property to determine whether an item is selected in a ListView control. This code example is part of a larger example provided for the DeleteItem method.
protectedvoid DeleteButton_Click(object sender, EventArgs e)
//Check if an item is selected to delete it.if (ContactsListView.SelectedIndex >= 0)
Message.Text = "No contact was selected.";
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)