本文介绍了DataGridView 垂直滚动条未正确更新(表单错误?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 .NET 3.5 中遇到了一个错误(我假设).使用 Rows.Add() 向 DataGridView 添加行时,在禁用 DGV 的情况下,垂直滚动条不会正确更新.因此,您无法在重新启用 DGV 后使用滚动条或鼠标滚轮一直滚动到 DGV 的底部(不过,使用箭头键导航仍然有效.)

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 properly. Consequently you can't scroll all the way to the bottom of the DGV using the scrollbar or the mouse wheel after reenabling the DGV (navigating with arrow keys still works, though.)

所以我正在寻找解决方法.有没有办法强制滚动条更新其边界,或者您可以手动输入新的最大值?我宁愿不必重新填充 DGV.

So I'm looking for a workaround. Is there a way to force the scrollbar to update its bounds or can you manually input a new maximum value? I'd rather not have to repopulate the DGV.

*) 实际上,禁用的是父窗体,但我认为问题在于它会传播到 DGV 控件.

*) Actually, it's the parent form that's disabled, but I assume the problem is that it propagates to the DGV control.

推荐答案

我刚刚遇到了这个问题(我的表单在添加行时被禁用)并通过在添加之前将网格的滚动条属性设置为无"来解决它添加完所有行后,将行设置回Both".

I've just had this problem (my form was disabled while adding rows) and solved it by setting the scrollbar property of the grid to 'None' before adding the rows then setting it back to 'Both' once all my rows have been added.

这篇关于DataGridView 垂直滚动条未正确更新(表单错误?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 07:02