Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8095319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:05:12+00:00 2026-06-05T21:05:12+00:00

I have a virtual datagridview that I want to set varying row heights for.

  • 0

I have a virtual datagridview that I want to set varying row heights for. I was hoping to find a method for setting all the row heights at once, rather than looping through each one at a time.

This is the method that I tried to set the heights, but the performance is horrible ~1 second per 1,000 rows. For me, an average row count is ~20k-30k rows so this is unacceptable.

public void PopulateData()
    {
        this.SuspendLayout();

        this.RowCount = Data.RowCount;

        for (int i = 0; i < Data.RowCount; i++)
        {
            this.Rows[i].Height = Data.RowHeights[i];
        }

        this.ResumeLayout();
    }

I made sure to turn off auto-sizing first also, but performance is still poor.

this.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
        this.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;

Is there any way to pass in an array of row heights or prevent OnRowHeightChanged from being called when resizing rows?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:05:15+00:00Added an answer on June 5, 2026 at 9:05 pm

    Apparently if you create the rows independently of the datagridview, the performance-hindering features do not apply.

    The trick is to create an array of rows, size them, and then add the range of rows to the datagridview afterwards:

    public void PopulateData()
        {
            this.SuspendLayout();
    
            DataGridViewRow[] rows = new DataGridViewRow[Data.RowCount];
            for (int i = 0; i < rows.Length; i++)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.Height = Data.RowHeights[i];
                rows[i] = row;
            }
            this.Rows.AddRange(rows);
    
            this.ResumeLayout();
        }
    

    For 15,000 rows this only took 150 ms compared to 15 seconds without creating a seperate array, 100 times faster!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this virtual method: const string& my_class::to_string() const { string str(this->name + string(
I have a virtual field weight that changes based on the difference in time
I have a virtual class Element that forces its derived classes to have a
I have virtual memory size set to 756 MB on windows xp. but when
I have Angle class that I want initialized to a random value. The Angle
I have Virtual PC 2007. I am writing a C# program that will run
I have virtual machine that has windows 7 + visual studio 2010 setup, and
I have a DataGridView in virtual mode. I only implemented the CellValueNeeded eventhandler as
I have a base resource that contains pure virtual functions like load and unload.
I'm trying to implement datagridview's virtual mode but when i set RowCount to some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.