Why Datagridview Scrolling is slow

jewel 1,231 Reputation points
2022-01-19T14:08:31.207+00:00

I am trying to create a project on VB.net. I have a checkbox column attached to the datagridview and one of the data that I have added to the Datagridview has an image column.
I want to hide this image column and show the images in the picture box.
The matter has been successfully completed. The problem is - when scrolling down the keyboard or mouse over Datagridview data, scrolling is slow.
If I don't hide the image column, it doesn't cause any problem.
I would have benefited if an expert had wasted his precious time and collaborated on the solution. Thanks in advance

Sub display_data()

        Dim cmd As New SqlCommand("select * from tbl_pro", con)
        cmd.Parameters.Add("@d1", SqlDbType.NVarChar).Value = Cmb_cmp.Text
        Dim da As New SqlDataAdapter(cmd)
        Dim dt As New DataTable
        dt.Clear()
        da.Fill(dt)
        DataGridView1.DataSource = dt

        DataGridView1.RowTemplate.Height = 20
        DataGridView1.Columns(1).Visible = False
        DataGridView1.Columns(3).Visible = False
        DataGridView1.Columns(4).Visible = False
        DataGridView1.Columns("Picture").Visible = False
        DataGridView1.Columns(0).ReadOnly = True
        DataGridView1.Columns(2).ReadOnly = True
        DataGridView1.Columns(5).ReadOnly = True
        DataGridView1.Columns(6).ReadOnly = True
        DataGridView1.Columns(8).ReadOnly = True
        DataGridView1.Columns(9).ReadOnly = True
        DataGridView1.Columns(10).ReadOnly = True
        DataGridView1.Columns(11).ReadOnly = True
        DataGridView1.Columns(12).ReadOnly = True


End Sub
Developer technologies | VB

Answer accepted by question author
Jiachen Li-MSFT 34,241 Reputation points Microsoft External Staff
2022-01-20T02:44:51.057+00:00

Hi @jewel ,
You can try setting the DoubleBuffered property of Datagriview.

Imports System.Reflection  

166625-image.png
And use DoubleBuffered(dataGridView1, true).
Hope this could be helpful.
Best Regards.
Jiachen Li

----------

If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.