Hello good people,
I need someone to tell me that I have not lost My sanity, why? Because what I am going to ask about is just silly. Ok here we go:
I have one ListView that is getting populated with file names. I want it to use multiple selection but like in "Windows Commander" by simply using up/down arrow keys and selecting rows by simply hitting space. I have created Key Up event catching space button being released, in that even Im getting index of currently selected (highlighted) row and adding it to my List<int>. Everything works like a charm.
I have created another event for my ListView, ItemSelectionChanged and in this Event I have a little loop:
private void listViewLeft_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
if (!e.IsSelected)
{
foreach (int selectedIndex in multipleSelectionArray)
{
Console.WriteLine(selectedIndex.ToString());
listViewLeft.Items[selectedIndex].Selected = true;
}
}
}
All peachy but whenever I'm trying to use listViewLeft.SelectedItems.Count it returns 0 or 1, randomly. The best thing is if I select rows using ctrl and mouse it works like a charm.
What am I missing? Whats the difference between listViewLeft.Items[selectedIndex].Selected = true and selecting rows by using mouse?
Don't get me wrong I can work around it simply by counting items in my List<int> but it just annoys me because I never had a problem like this.
Thank you for your time and I do apologize if I over complicated things ;)
Wajrak