0

I have four List<ListViewItem> and one listView control.

What I want is to populate the control with the items from the lists.

How can I do it?

walkman
  • 478
  • 1
  • 8
  • 21

1 Answers1

1

What I would do is first merge the four lists into one and then add them to the ListView's Items collection.

var allListItems = list1.Concat(list2)
                        .Concat(list3)
                        .Concat(list4)
                        .ToList();

listView.Items.AddRange(allListItems);

This is not very pretty or the best performing solution but it does the job. Take a look at this thread to get a better idea on how to merge more than one list to one.

Community
  • 1
  • 1
Timo Salomäki
  • 7,099
  • 3
  • 25
  • 40