I'm attempting to use WinListView's SelectedItems properties. However, if I select more than 2 items, it only contains the first and last items selected. Is this expected behavior?
Thanks.
-Nick
My function IncludeItem removes values from lstAvailableItems. Something in the internals of SelectedItems gets screwed up when values are removed and the next selected item is skipped. I've worked around this by creating a temporary list of the selected items.
Still not able to reproduce. Yes, the SelectedItems collection will work as expected in this case, i.e., the IncludeItem method will be called for each selected item. I assume you put a breakpoint inside the foreach loop to confirm that the SelectedItems collection was indeed returning less items than you actually selected; if this is the case, you should report the issue as a bug so that you can provide a test project which enables us to reproduce this behavior.
I'm not using it in the list box's event. I have a button that gets pressed, and then have the following code:
private void btnAddItem_Click(object sender, EventArgs e) { foreach (UltraListViewItem item in lstAvailableItems.SelectedItems) { IncludeItem(item); } }
Will SelectedItems work as I expect it to in this case?
I could not reproduce the behavior you describe here with a simple test. I handled ItemSelectionChanged and iterated the e.SelectedItems therein and all selected items were enumerated.