title: C# DataGridView, large cells: Content never fully visible, scrolling skips cell
body: <p>I have encountered a rather nasty problem with the <code>DataGridView</code> control (Windows.Forms, .NET Framework 3.0) when there is a <code>DataGridViewCell</code> that is larger than the DataGridView itself. When the large cell is scrolled into view it displays normally, cut off at the bottom since it is larger than the view. If you scroll down further it eventually "snaps" at the top and stays there, until you reach a certain threshold. Then, the next row will be displayed at the top and the "large" row disappears.</p>
  
  <p>Because of that you are never able to fully see the contents of the large cell.</p>
  
  <p>Here's an example code:</p>
  
  <pre><code>using System;
  using System.Windows;
  
  namespace LoggerTextBox {
  public class TestForm : Form
  {
      public TestForm()
      {
          Text = "DataGridView Large Cell Example";
          SetBounds(0, 0, 300, 200, BoundsSpecified.Width | BoundsSpecified.Height);
  
          DataGridView dataGridView = new DataGridView();
          dataGridView.Dock = DockStyle.Fill;
          dataGridView.ScrollBars = ScrollBars.Both;
          dataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;
          Controls.Add(dataGridView);
  
          DataGridViewColumn column = new DataGridViewTextBoxColumn();
          column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
          column.CellTemplate.Style.WrapMode = DataGridViewTriState.True;
          dataGridView.Columns.Add(column);
  
          // normal row
          DataGridViewRow row = new DataGridViewRow();
          DataGridViewCell cell = (DataGridViewTextBoxCell)column.CellTemplate.Clone();
          cell.Value = "Foo";
          row.Cells.Add(cell);
          dataGridView.Rows.AddRange(row);
  
          // multiline row
          row = new DataGridViewRow();
          cell = (DataGridViewTextBoxCell)column.CellTemplate.Clone();
          cell.Value =
              "Lorem ipsum dolor sit amet, consetetur sadipscing elitr," + Environment.NewLine +
              "sed diam nonumy eirmod tempor invidunt ut labore et doloreLorem," + Environment.NewLine +
              "ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy," + Environment.NewLine +
              "eirmod tempor invidunt ut labore et dolore magna aliquyam erat,," + Environment.NewLine +
              "sed diam voluptua. At vero eos et accusam et justo duo dolores et," + Environment.NewLine +
              "ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est," + Environment.NewLine +
              "Lorem ipsum dolor sit amet. magna aliquyam erat, sed diam voluptua.," + Environment.NewLine +
              "At vero eos et accusam et justo duo dolores et ea rebum. Stet clita," + Environment.NewLine +
              "kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
          row.Cells.Add(cell);
          dataGridView.Rows.AddRange(row);
  
          // normal row
          row = new DataGridViewRow();
          cell = (DataGridViewTextBoxCell)column.CellTemplate.Clone();
          cell.Value = "Bar";
          row.Cells.Add(cell);
          dataGridView.Rows.AddRange(row);
      }
  
      /// &lt;summary&gt;
      /// The main entry point for the application.
      /// &lt;/summary&gt;
      [STAThread]
      static void Main()
      {
          Application.EnableVisualStyles();
          Application.SetCompatibleTextRenderingDefault(false);
          Application.Run(new TestForm());
      }
  }
  } // namespace
  </code></pre>
  
  <p>Any idea how to fix this?</p>