Save the prior value and then reset it to the prior.
int lastIndex = -1;
if (q)
{
lastIndex = (ListView)Sender.SelectedIndex;
}
else
{
// Stop change from happening
(ListView)Sender.SelectedIndex = lastIndex;
}
2
solved How can I prevent a ListView option from changing? [closed]