gpt4 book ai didi

.net - 键入时自动滚动 DataGridView

转载 作者:行者123 更新时间:2023-12-01 15:05:05 26 4
gpt4 key购买 nike

我遇到这个问题,DataGidView 中的最后一列太长,您需要使用滚动条才能显示该列的其余部分。
但是当我输入文本时,它不会在输入时自动滚动。


我想要的是在输入时自动滚动滚动条,这样用户在输入时就不必使用滚动条了。

这是图片:

The datagridview如您所见,最后一栏是备忘录。
当我在备忘录中键入文本时,它不会自动滚动。如何实现?

最佳答案

查看以这种方式修改的单元格滚动行为是否可以在您的上下文中使用。

输入的Cell用DataGridView.GetCellDisplayRectangle()测量而且,如果它是 Right位置超出DataGridView边界,Cell在电流设置为 FirstDisplayedCell 之前.
这应该确保单元格在输入时始终滚动到 View 中。
在编辑模式下,Cell 的边界会自动扩展。

此外,检查 cutOverflow GetCellDisplayRectangle() 的参数考虑 Cell 时行为略有不同的方法边界范围。

Private Sub DataGridView1_CellEnter(sender As Object, e As DataGridViewCellEventArgs)
Dim cellArea = DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, False)
If cellArea.Right > DataGridView1.Width AndAlso e.ColumnIndex > 0 Then
DataGridView1.FirstDisplayedCell = DataGridView1(e.ColumnIndex - 1, e.RowIndex)
End If
End Sub

关于.net - 键入时自动滚动 DataGridView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51604395/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com