Im using a multi-select ListView in C# .NET 4.5The issue occurs when selecting multiple items (ie. Shift + End or Shift + Click, etc.) These are just a few examples of many different mouse/keyboard combinations for multi-selecting of course..
This is my event handler for when selecting items in a list:
private void lvTitles_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e){ MessageBox.Show(e.Item.Text.ToString()); //MessageBox just for testing I am actually running a SQL query here}
My problem is that if I select 500 items the event is triggered 500 times. The intent is to get that last item the user selected (via keyboard/mouse combinations mentioned above), on and do something with it ... in my case I need to run a SQL query against it.
If I click first on item 0 in the listview it is ok to run the query, then when you shift+end it highlights all the rest, and I want it to run the query only on the last item selected. Instead it is running on every item in between.
EDIT: On another note, the event triggers as it unselects as well, in which case it really shouldn't do anything when deselecting.