Question : Scrolling Issue With DataGridView & Wrapping Text

I'm fairly new to 2.0, and I've been looking to move to it to solve a problem I was having with DataGrids with multiline textboxes not scrolling properly when the row is bigger than the displayable area of the grid.

I was eagerly looking forward to getting to 2.0 and the DGV to hopefully alleviate the problem, but no dice.

When I have a row that has a column with word-wrapping on, and the DGV uses AutoResizeRows, if the cell's text display requirements are greater than the DGV's display area, the scrolling behavior for the grid seems to want to bring the next row to the top, even though I haven't viewed the last 2 sentences of the previous row.

In other words, if the row is too big, the text gets cut off, and I can't scroll to view the rest of the contents of the row. If there are rows after that row, it skips the hidden content to move the next row to the top of the display, if it's the last row, it will only scroll until the top of the row is at the top of the control, but it won't scroll past that point, so the remaining data remains hidden.

Any ideas?

Here's the code in question:

      this.dsTest = new DataSet();
      DataTable tbl = new DataTable("Comments");
      tbl.Columns.Add("UserID");
      tbl.Columns.Add("TimeStamp", typeof(DateTime));
      tbl.Columns.Add("Text");
      tbl.AcceptChanges();
      dsTest.Tables.Add(tbl);
      dsTest.AcceptChanges();

      this.addRows();

      BindingSource bSource = new BindingSource();
      bSource.DataSource = dsTest.Tables[0];
      dgTest.RowHeadersVisible = false;
      dgTest.AutoGenerateColumns = false;

      DataGridViewColumn col = new DataGridViewColumn(new DataGridViewTextBoxCell());
      col.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
      col.HeaderText = "Made By";
      col.DataPropertyName = "UserID";
      col.CellTemplate.Style.Alignment = DataGridViewContentAlignment.TopLeft;
      col.Width = 75;

      dgTest.Columns.Add(col);

      col = new DataGridViewColumn(new DataGridViewTextBoxCell());
      col.HeaderText = "Made At";
      col.DefaultCellStyle.Format = "HH:mm:ss";
      col.DataPropertyName = "TimeStamp";
      col.CellTemplate.Style.Alignment = DataGridViewContentAlignment.TopLeft;
      col.Width = 60;

      dgTest.Columns.Add(col);

      col = new DataGridViewColumn(new DataGridViewTextBoxCell());
      col.HeaderText = "Comment";
      col.DataPropertyName = "Text";
      col.CellTemplate.Style.Alignment = DataGridViewContentAlignment.TopLeft;
      col.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
      col.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

      dgTest.Columns.Add(col);

      dgTest.DataSource = bSource;
      dgTest.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllCells);

Answer : Scrolling Issue With DataGridView & Wrapping Text

mrobold,
Because you have presented a solution to your own problem which may be helpful to future searches, this question is now PAQed and your points have been refunded.

EE_AutoDeleter
Random Solutions  
 
programming4us programming4us