|
-
Nov 8th, 2022, 07:06 AM
#1
Thread Starter
New Member
Datagridview redraw issue during horizontal scroll
Hello,
I have been searching the forums up and down to find a solution for the awfull redrawing of the datagridviews when scrolling but so far nothing works. The issue is with the "moving" of the datagriview control itself, not the row scrolling.
To explain it more simply, here is a link to a short video i recorded after running the app: https://gifyu.com/image/SE0kx
As you can see, the redrawing of the DGV's is quite bad.
The code i use to create them is:
Code:
Dim dgv As New DataGridView
dgv.Name = myValue
DoubleBuffer(dgv)
Dim c As Integer = 1
Dim r As Integer = cbList.Items.Count
For cc As Integer = 0 To c - 1
Dim nc As New DataGridViewTextBoxColumn
nc.Name = myValue
dgv.Columns.Add(nc)
dgv.Columns(0).SortMode = DataGridViewColumnSortMode.NotSortable
dgv.Columns(0).Width = 130
With dgv
.ColumnHeadersDefaultCellStyle.Font = New Font("Arial", 10.0F, FontStyle.Bold)
.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.RowsDefaultCellStyle.Font = New Font("Arial", 9.0F, FontStyle.Regular)
.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.AllowUserToResizeColumns = False
.AllowUserToAddRows = False
.RowHeadersVisible = False
.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing
.Height = 410
.Width = 150
.DefaultCellStyle.BackColor = Color.Orange
.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing
End With
Next
Dim dr As DataRow = dt.NewRow
dt.Rows.Add(dr)
For Each file As FileInfo In fileinfo
If file.Extension.ToString = ".db" Or file.Extension.ToString = ".jpg" Then
Else
nm = file.Name
nm = nm.Substring(0, nm.IndexOf(".")).Trim()
If nm.Contains("_") Then
nm = nm.Substring(0, nm.IndexOf("_")).Trim()
End If
cbList.Items.Add(nm)
dgv.Rows.Add(nm)
Dim dr2 As DataRow = dt2.NewRow
Dim dr3 As DataRow = dt3.NewRow
Dim dr4 As DataRow = dt4.NewRow
dr2("PN list") = nm
dr3("Main PN list") = nm
dr4("Associated PN list") = nm
dt2.Rows.Add(dr2)
dt3.Rows.Add(dr3)
dt4.Rows.Add(dr4)
bsData2.DataSource = dt2
bsData3.DataSource = dt3
bsData5.DataSource = dt4
dgvSearch.DataSource = bsData2
dgvPNlistA.DataSource = bsData3
dgvPNlistB.DataSource = bsData5
End If
Next
dgvSearch.Columns(0).Width = 180
dgvPNlistA.Columns(0).Width = 180
dgvPNlistB.Columns(0).Width = 180
dgvPanel.Controls.Add(dgv)
And i also use the DoubleBuffer trick:
Code:
Private Sub DoubleBuffer(ByVal dgv As DataGridView)
Dim dgvType As Type = dgv.[GetType]()
Dim pi As PropertyInfo = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance Or BindingFlags.NonPublic)
pi.SetValue(dgv, True, Nothing)
End Sub
Is there any possibility to improve the rendering performance of the DGV's? Also, it has no connection to the performance of the PC.
I tried with "Causes Validation = False"; double buffering the entire Form, creating a new DGV class with doublebuffer, nothing works. Im starting to think that this has no solution.
Also, I need these DGV's created individually since I have other functions regarding them (no RowPrepaint) only cell color with fixed conditions. Tried disabling everything, using basic DGV settings, the issue is the same.
Tags for this Thread
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
|