Home > DeveloperSection > Forums > How can I make a ListView update after each item is added in C#?
Pravesh Singh
Pravesh Singh

Total Post:101

Points:709
Posted on    July-17-2013 4:08 AM

 C# C# 
Ratings:


 0 Reply(s)
 1072  View(s)
Rate this:
Hi mindstick!

I am trying to use a ListView to make a realtime log output to a windows form.

This is the dummy code:

 public Form1()

    {

        InitializeComponent();

        listView1.View = View.Details;

        listView1.GridLines = false;

        listView1.Scrollable = true;

        listView1.FullRowSelect = true;

        listView1.Columns.Add("Track");

        listView1.Columns.Add("Status");

        for (int i = 1; i <= 10000; i++)

        {

            ListViewItem LVI = new ListViewItem("Track " + i);

            LVI.SubItems.Add("Updated");

            listView1.Items.Add(LVI);

            listView1.TopItem = LVI;

            listView1.EnsureVisible(listView1.Items.Count - 1);

        }

    }

How can I set it so it refreshes after each line is added? At the moment the application waits until the list is generated and then loads the form with the complete list.

Thanks in advance



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

Follow MindStick