Code Optimization

Interesting things about software development and code optimization

DataGridView and huge amount of data rows

Hello my friends,

Did you have a need to populate the DataGridView control with a lot of data? I'm sure you did have.

If you have a huge amount of rows, like 10 000 and more, you will see a huge problem in performance.

To avoid performance leak - you need to set proper value into the RowHeadersWidthSizeMode property.

So the best way is to disable auto resizing during data binding:

dataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;

you actually can set EnableResizing but avoid to use the DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders

The AutoSizeToAllHeaders is most time consumable parameter.

In addition would be better to set the RowHeadersVisible to false

dataGridView1.RowHeadersVisible = false;

Now you can bind data source, and enable it all or set what you want it to be 


Thank you, see you next time.


1vqHSTrq1GEoEF7QsL8dhmJfRMDVxhv2y



Comments (3) -

  • Theresa

    1/13/2016 5:04:25 PM | Reply

    I really liked the content. Thanks for the useful information. It is really helpful to me.

  • OKarpov

    1/13/2016 5:11:04 PM | Reply

    Thank you, let me know, please, if you have any other interesting questions and need assistance on them Smile

  • Eula Maglaras

    10/18/2018 11:38:24 AM | Reply

    But wanna  input on few general things, The website  design and style  is perfect, the  subject material  is  real   fantastic  : D.

Loading