In the ListView control, I need to fire the event after changing the selection, but only once for each user action. If I just use SelectedIndexChanged, this event fires twice in most cases (once when the previous item is not selected and again when a new item is selected) if the user just clicked on the control once .
Two events fire quickly one after another, but the calculation that I perform when I change the selection takes time (almost a second), so it runs twice and slows down the interface.
What I want to do is to do it only once per user action (doing it before the new item is selected is useless), but I donβt know if the event is only the first of the pair (to skip the first calculation), because if the user simply deselected the selected item, it will fire only once.
I cannot use the Click or MouseClick events because they do not fire at all if the user clicked outside the list to remove the selection.
Thank you for your help.
source share