HOW TO ADD LIST IN LISTVIEW IN C#

Anupam Mishra

Total Post:135

Points:949
Posted by  Anupam Mishra
C#  .NET 
C#
 1012  View(s)
Ratings:
Rate this:
Hi All,
I have created one listview and i want to adding a new list in a listview. Please give me a solution.
Thank you.
  1. Anupam Mishra

    Post:135

    Points:949
    Re: How to add list in listview in C#

    In this case we would need to have list that could be called in foreach loop .

    Here, we are using a list as string type i.e List<String> list = new List<String>();



    private void Form1_Load(object sender, EventArgs e)
            {
                List<string> mylist = new List<string>() { "Hi ", "I am", "List" };
                foreach (string elem in mylist)
                {
                    listView1.Items.Add(new ListViewItem(elem));
                }
              
            }

    Output:


Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!