Occurs when the SelectedIndices collection changes.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The SelectedIndices collection changes whenever the Selected property of a ListViewItem changes. The property change can occur programmatically or when the user selects an item or clears the selection of an item. When the user selects an item without pressing CTRL to perform a multiple selection, the control first clears the previous selection. In this case, this event occurs one time for each item that was previously selected and one time for the newly selected item.
To determine which items are selected in the ListView control, use the SelectedItems property to access the ListView.SelectedListViewItemCollection. You can create an event handler for this event to perform tasks whenever there is a change to the selected items in the ListView control.
For more information about handling events, see Handling and Raising Events.
The following code example demonstrates how to use the SelectedItems property, event, HeaderStyle members, and the ListView.SelectedListViewItemCollection class. To run this example, paste the following code into a form that contains a ListView object named ListView1 and a TextBox named TextBox1. Call the InitializeListView method from the form's constructor or Load method. This example requires that the event handler is correctly associated with the event