title: .NET Listview Refresh
body: <p>I have the following code, which basically takes values from a database and populates a listview.</p>
  
  <pre><code>using (IDataReader reader = cmd.ExecuteReader())
  {                    
      lvwMyList.Items.Clear();
      while (reader.Read())
      {
          ListViewItem lvi = lvwMyList.Items.Add(reader["Value1"].ToString());
          lvi.SubItems.Add(reader["Value2"].ToString());                    
      }
  }
  </code></pre>
  
  <p>The problem that I have is that this is repeatedly executed at short intervals (every second) and results in the items in the listview continually disappearing and re-appearing.  Is there some way to stop the listview from refreshing until it’s done with the updates?  Something like below:</p>
  
  <pre><code>using (IDataReader reader = cmd.ExecuteReader())
  {                    
      lvwMyList.Items.Freeze(); // Stop the listview updating
      lvwMyList.Items.Clear();
      while (reader.Read())
      {
          ListViewItem lvi = lvwMyList.Items.Add(reader["Value1"].ToString());
          lvi.SubItems.Add(reader["Value2"].ToString());                    
      }
      lvwMyList.Items.UnFreeze(); // Refresh the listview
  }
  </code></pre>