title: DataGridView won't repaint itself when updated from another thread
body: <p>I have a problem updating <code>DataGridView</code> from another thread. Let me explain. When user clicks a button on a form I need to populate the grid with some rows. This process takes some time, so I'm doing it in a separate thread. Before starting the thread I set <code>DataGridView.Enabled</code> property to <code>false</code>, to prevent user from editing items while they are being added, and just before the working thread ends I set <code>Enabled</code> back to <code>true</code>.</p>
  
  <p>The problem is <code>DataGridView</code> won't update its contents correctly if scrollbars need to be shown. I'll illustrate this with a screenshot:</p>
  
  <p><img src="https://i.stack.imgur.com/Hbype.png" alt="partially drawn row"></p>
  
  <p>As you can see, the last visible row is partially drawn and the <code>DataGridView</code> won't scroll down. If I resize the grid, making it to repaint itself, all rows appear normally.</p>
  
  <p>Here is some code:</p>
  
  <pre><code>    private void button1_Click(object sender, EventArgs e)
      {
          string[] fileNames = new string[] { "file1", "file2", "file3" };
          Thread AddFilesToListThread = new Thread(ThreadProcAddRowsToGrid);
          dataGridView1.Enabled = false;
          AddFilesToListThread.Start(fileNames);
      }
  
      delegate void EmptyDelegate();
  
      private void ThreadProcAddRowsToGrid(object fileNames)
      {
          string[] files = (string[])fileNames;
          foreach (string file in files)
          {
              EmptyDelegate func = delegate
              {
                  dataGridView1.Rows.Add(file);
              };
              this.Invoke(func);
          }
  
          EmptyDelegate func1 = delegate
          {
              dataGridView1.Enabled = true;
          };
          this.BeginInvoke(func1);
      }
  </code></pre>
  
  <p>I've also notices that only <code>Enabled</code> property causes this strange behaviour. Changing, for example, <code>BackgroundColor</code> works fine.</p>
  
  <p>Could you help me see where the problem is?</p>