How can I cast ListView.Items
to a List
?
This is what I tried:
List list = lvFiles.Items.Cast
Try this using the Select
method:
for list text:
List listText = lvFiles.Items.Select(item => item.Text).ToList();
for list values:
List listValues = lvFiles.Items.Select(item => item.Value).ToList();
Or maybe, for both:
Dictionary files = lvFiles.Items.ToDictionary(key => key.Value, item => item.Text);