Good Day,
I am facing this issue in one of the VB .Net app I have. I am populating a datagridview. When scrolling the view to left or right to see other columns, the view appears bit distorted or broken. See attached image. Wondering if there's any fix to prevent this?
CodePudding user response:
The rendering problem can be solved by invoking a Refresh()
on the grid handling the Scroll
event:
Private Sub DataGridView1_Scroll(sender As Object, e As ScrollEventArgs) Handles DataGridView1.Scroll
DataGridView1.Refresh()
End Sub
To avoid flickering when scrolling, I thought it was enough to do a type check
If e.Type = ScrollEventType.EndScroll Then DataGridView1.Refresh()
However, it seems that the EndScroll
Type is never assigned due to a bug: DataGridView Scroll event (and ScrollEventType.EndScroll)
Anyway, there is a solution to this problem. You can directly handle scrollbar events to get the correct ScrollEventType: How can I receive the "scroll box" type scroll events from a DataGridView?