DataGridView vertical scrollbar not updating properly (Forms bug?)

后端 未结 14 1913
伪装坚强ぢ
伪装坚强ぢ 2021-01-03 23:49

I\'ve encountered a bug (I assume) in .NET 3.5. When adding rows to a DataGridView using Rows.Add(), while the DGV is disabled, the vertical scrollbar doesn\'t update proper

14条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-03 23:55

    If none of the other given solution worked for you, I came across a similar issue with vertical scrollbar in DataGridView. But the issue is like whenever the number of rows extend beyond the height of the datagridview, vertical scrolling created a messed up UI. Kind of rows overlapping each other.

    I had a databound DataGridView.

    These are the list of things I tried but didn't work.

    1. Setting the ScrollBars property to None, modify datasource and then set the ScrollBars property to Both.
    2. Using SuspendLayout, ResumeLayout and PerformLayout at various combinations.
    3. Set Double Buffering for the DataGridView using extension method.

    Finally, Setting AutoSizeRowsMode to DataGridViewAutoSizeRowsMode.AllCells fixed the issue for me.

    If you have similar issue with horizontal scrolling, I think playing with AutoSizeColumnsMode should fix the issue.

提交回复
热议问题