When using ListView multiselect how do I manage all selected items? #1518
-
How do I manage the process of getting all selections from a multiselect with ListView? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
To be clear when you talk about 'getting all selections' you are meaning these right? If you have a list of objects that you provided as the So for example if you have a myList.Where((e, idx) => lv.Source.IsMarked(idx)) If you don't have a copy of your original list (i.e. lv.Source.ToList().Cast<object>().ToList().Where ((e,idx)=>lv.Source.IsMarked(idx)) |
Beta Was this translation helpful? Give feedback.
To be clear when you talk about 'getting all selections' you are meaning these right?
Tick indicates marked items
If you have a list of objects that you provided as the
Source
for the ListView then you can get those that have been multi selected (ticked) by using thebool IsMarked(int)
method of the source. It takes the index of the list and returns true/false for whether it is ticked.So for example if you have a
ListView
calledlv
and aList
(of data objects) calledmyList
you could use the following Linq:If you don't have a copy of your original list (i.e.
myList
) you could still get the list of objects with something like (you could…