Search code examples
c#listviewlistviewitem

ListView.Items.Add adding a ListViewItem to wrong ListView


I have two ListView objects in my code, MovieList and UserFriendList. I have a method that looks like this

public void passFriends(ListViewItem[] friends)
    {
        foreach (ListViewItem tempItem in friends)
        {
            ListViewItem temp = new ListViewItem();
            temp = (ListViewItem)tempItem.Clone();
            UserFriendList.Items.Add(temp);
        }
    }

The method is designed to pass an array of ListViewItems from one form to another, and then add each listview item to the UserFriendList. However, when I actually perform the action, the ListViewItem (a User) is added to my MovieList instead of my UserFriendsList

Does anybody know why this could be happening?


Solution

  • This question can be closed. I found the issue with my problem. A section of legacy code that was used to demonstrate list switching wasn't removed and it was changing the listview of UserFriendList