Why Datagridview Scrolling is slow

jewel 801 Reputation points

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
        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
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,601 questions
{count} votes

Accepted answer
  1. Jiachen Li-MSFT 27,241 Reputation points Microsoft Vendor

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

    Imports System.Reflection  

    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful