|
-
May 21st, 2016, 06:22 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] DataGridView visible interference while scrolling
I have a datagridview on a form which displays data. The datagridview scrolls both horizontally and vertically. It works but when I scroll to the right and then scroll up and down you can see flashes of gray on the view during the scroll. Once you stop scrolling the gray disappears. This affects approximately the right third of the dgv. If I don't scroll to the right and scroll up and down I don't see these artifacts. What can I do to get rid of these flashes of gray while vertical scrolling?
-
May 22nd, 2016, 03:41 PM
#2
Re: DataGridView visible interference while scrolling
Hello,
Are there any events you have the DataGridView subscribed to e.g. CellFormatting etc.
-
May 22nd, 2016, 04:24 PM
#3
Thread Starter
Fanatic Member
Re: DataGridView visible interference while scrolling
There is a cellclick event.
-
May 22nd, 2016, 09:17 PM
#4
Thread Starter
Fanatic Member
Re: DataGridView visible interference while scrolling
Removing the cellclick handler made no difference.
The part of the dgv where the artifacts appear is on the right side and corresponds, almost, to the part which cannot be seen when the dgv is scrolled fully left.
-
May 24th, 2016, 01:52 PM
#5
Re: DataGridView visible interference while scrolling
Try subclassing your DGV and making it DoubleBuffered:
Code:
Public Class DoubleBufferedDataGridView
Inherits DataGridView
Public Sub New()
Me.DoubleBuffered = True
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 24th, 2016, 02:15 PM
#6
Thread Starter
Fanatic Member
Re: DataGridView visible interference while scrolling
Thanks. I've never heard of a double-buffered datagridview. My dgv is created with code. Simply adding "DoubleBuffered" to the declaration did not work. What to do?
Code:
Dim ReportDataGridView as DataGridView
Code:
ReportDataGridView = New DataGridView
ReportDataGridView.Name = "Stock Items Report"
ReportDataGridView.Left = 14
ReportDataGridView.Top = 82
ReportDataGridView.Height = 520
ReportDataGridView.Width = 956
ReportDataGridView.BorderStyle = BorderStyle.None
ReportDataGridView.RowsDefaultCellStyle.SelectionBackColor = Color.DarkKhaki
ReportDataGridView.RowsDefaultCellStyle.SelectionForeColor = Color.Black
ReportDataGridView.RowsDefaultCellStyle.BackColor = Color.LightYellow
ReportDataGridView.RowsDefaultCellStyle.Font = New Font("Microsoft Sans Serif", 12)
ReportDataGridView.AlternatingRowsDefaultCellStyle.BackColor = Color.PaleGoldenrod
ReportDataGridView.ColumnHeadersDefaultCellStyle.Font = New Font("Microsoft Sans Serif", 11)
ReportDataGridView.ColumnHeadersHeight = 28
ReportDataGridView.AllowUserToAddRows = False
ReportDataGridView.AllowUserToDeleteRows = False
AddHandler ReportDataGridView.CellClick, AddressOf ReportDataGridView_CellClick
Controls.Add(ReportDataGridView)
-
May 24th, 2016, 02:57 PM
#7
Re: DataGridView visible interference while scrolling
Add the DoubleBufferedDataGridView class to your project (from post #5), then:
Code:
Dim ReportDataGridView as DoubleBufferedDataGridView
Code:
ReportDataGridView = New DoubleBufferedDataGridView
It will automatically be doublebuffered with no further code, and the dgv will be as a standard dgv except double buffering, which will hopefully improve the graphics performance...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 24th, 2016, 06:18 PM
#8
Thread Starter
Fanatic Member
Re: DataGridView visible interference while scrolling
When I change Dim ReportDataGridView as DataGridView to Dim ReportDataGridView as DoubleBufferedDataGridView I get the message "Type DoubleBufferedDataGridView is not defined". I'm using Visual Basic 2010 Express.
-
May 24th, 2016, 06:23 PM
#9
Re: DataGridView visible interference while scrolling
Did you add a class, name it DoubleBufferedDataGridView and paste the code from post #5 into the class as i told you to do?
DoubleBufferedDataGridView is a custom control. It is necessary because that is the only way to apply double buffering to a dgv.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 24th, 2016, 07:24 PM
#10
Thread Starter
Fanatic Member
Re: DataGridView visible interference while scrolling
It's working beautiflly! Thank you. You rate a 10.
-
May 24th, 2016, 07:28 PM
#11
Re: [RESOLVED] DataGridView visible interference while scrolling
Glad i was able to help. That was my best shot. If that hadn't worked it might've been unsolveable.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|