Home > DeveloperSection > Forums > How to add list in listview in C#
Anupam Mishra

Total Post:135

Points:949
Posted on    January-23-2016 3:06 AM

 C# C#  .NET 
Ratings:


 1 Reply(s)
 280  View(s)
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.


Anupam Mishra

Total Post:135

Points:949
Posted on    January-23-2016 7:11 AM

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:



Don't want to miss updates? Please click the below button!

Follow MindStick