title: Listview suspend and resume
body: <p>How do I get the SuspendLayout and ResumeLayout to work correctly in regards to a listview. I have added these lines of code before and after I have added the items, yet each item is still being displayed as I add each item.</p>
  
  <p>thanks</p>
  
  <ul>
  <li><p>My code:</p>
  
  <pre><code>    Dim x As Integer
  
  Dim startTick As Integer = Environment.TickCount
  
  lstFiles.SuspendLayout()
  
  For x = 0 To UBound(cacheListArray)
      If cacheListArray(x) Like "*.txt" Then
          lstFiles.Items.Add(cacheListArray(x))
      End If
  Next
  
  lstFiles.ResumeLayout()
  
  MsgBox(Environment.TickCount - startTick)
  </code></pre></li>
  </ul>
  
  <p>I am adding 2000 items. This takes 7 seconds. I was told that it should be a lot shorter than that. Is that correct?</p>
  
  <hr>
  
  <p>New code:</p>
  
  <pre><code>        Dim ListViewItemArray(-1) As ListViewItem
  
                  ReDim Preserve ListViewItemArray(UBound(ListViewItemArray) + 1)
              ListViewItemArray(UBound(ListViewItemArray)).Text = file.Name
              ListViewItemArray(UBound(ListViewItemArray)).SubItems.Add(file.FullName)
              ListViewItemArray(UBound(ListViewItemArray)).SubItems.Add(file.Length)
              ListViewItemArray(UBound(ListViewItemArray)).SubItems.Add(file.CreationTime)
              ListViewItemArray(UBound(ListViewItemArray)).SubItems.Add(file.LastWriteTime)
              ListViewItemArray(UBound(ListViewItemArray)).SubItems.Add(file.LastAccessTime)
  
          lstFiles.Items.AddRange(ListViewItemArray)
  </code></pre>
  
  <p>Nothing is being added. What have I done incorrectly?</p>