DataGridView (Stop it From Drawing)

  • Thread starter Thread starter NvrBst
  • Start date Start date
N

NvrBst

By default I have it set to
"DataGridView.AutoResizeColumns(DisplayedCells);" I let the user
change to "DataGridView.AutoSizecolumnsMode = Fill;" at runtime with a
button. When I do that it takes about 3 seconds during which time I
can see the bottom scroll bar shinking more and more till its done.

I've tried putting "DataGrideView.SuspendLayout();"
"DataGridView.ResumeLayout();" around the "AutoSeizcolumnsMode =
Fill;" but I still see the bottom scroll bar shrinking little by
little. I can do "Hide() / Show()" to hide the shirnking scrollbar
but it still takes 3 seconds to complete.

I think the DataGridView is drawing to display after each column
resize, when I only want it to set the widths and draw at the end. Is
there a way to do this? Is "SuspendLayout()" suppose to do this?

Thanks

NB
 
I don't think you can stop it from taking three seconds. How many rows
do you have in your view? I ask because in order to auto resize the
columns, it has to cycle through the rows, and calculate the sizes of the
elements in each column.

This means that every column value in every row has to be queried (and
more so, the renderers for that cell/column/row) to see what the size should
be. The grid will then make the determination as to how big each column
should be based on that information.

I suspect that if you tried it with a smaller subset of data, you would
see a performance improvement relative to the difference with the number of
rows that you have now.
 
    I don't think you can stop it from taking three seconds.  How many rows
do you have in your view?  I ask because in order to auto resize the
columns, it has to cycle through the rows, and calculate the sizes of the
elements in each column.

    This means that every column value in every row has to be queried (and
more so, the renderers for that cell/column/row) to see what the size should
be.  The grid will then make the determination as to how big each column
should be based on that information.

    I suspect that if you tried it with a smaller subset of data, you would
see a performance improvement relative to the difference with the number of
rows that you have now.

--
          - Nicholas Paldino [.NET/C# MVP]
          - (e-mail address removed)




By default I have it set to
"DataGridView.AutoResizeColumns(DisplayedCells);"  I let the user
change to "DataGridView.AutoSizecolumnsMode = Fill;" at runtime with a
button.  When I do that it takes about 3 seconds during which time I
can see the bottom scroll bar shinking more and more till its done.
I've tried putting "DataGrideView.SuspendLayout();"
"DataGridView.ResumeLayout();" around the "AutoSeizcolumnsMode =
Fill;" but I still see the bottom scroll bar shrinking little by
little.  I can do "Hide() / Show()" to hide the shirnking scrollbar
but it still takes 3 seconds to complete.
I think the DataGridView is drawing to display after each column
resize, when I only want it to set the widths and draw at the end.  Is
there a way to do this?  Is "SuspendLayout()" suppose to do this?

NB- Hide quoted text -

- Show quoted text -

I have thousands of rows in my table. It does go faster if there are
less rows in my table. The 3 second wait isn't bad for me; I was just
thinking that it was strange to be able to see the bottom scroll bar
shrink little by little, which threw me off (thinking that maybe it
can go faster if it didn't reset the size of the scroll constantly
(maybe its drawing to display constantly aswell) - Thinking "Why arn't
you just doing it once at the end after all the widths are set!" Kind
of thing).

Thanks for the reply :)

NB
 
I find the Fill mode makes it unusable,
I searched for a solution but seems to be slow whatever you do.
from what I read it seems it might well call paint etc to do the sizing
whatever you do.

It was sooo slow hardly suitable for a realtime didsplay.
I ended up turning off all autosize and just keeping track of the
column size when I fill it by using the length of the strings.
its still not realyfast, my table only has a few dozen rows,
but it cant fill the 3 tables with a new set of data fast enough
to keep up with key repeat when scrolling through lots of datasets,
this on a 3200+amd64 machine.


I don't think you can stop it from taking three seconds. How many rows
do you have in your view? I ask because in order to auto resize the
columns, it has to cycle through the rows, and calculate the sizes of the
elements in each column.

This means that every column value in every row has to be queried (and
more so, the renderers for that cell/column/row) to see what the size
should
be. The grid will then make the determination as to how big each column
should be based on that information.

I suspect that if you tried it with a smaller subset of data, you would
see a performance improvement relative to the difference with the number
of
rows that you have now.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




By default I have it set to
"DataGridView.AutoResizeColumns(DisplayedCells);" I let the user
change to "DataGridView.AutoSizecolumnsMode = Fill;" at runtime with a
button. When I do that it takes about 3 seconds during which time I
can see the bottom scroll bar shinking more and more till its done.
I've tried putting "DataGrideView.SuspendLayout();"
"DataGridView.ResumeLayout();" around the "AutoSeizcolumnsMode =
Fill;" but I still see the bottom scroll bar shrinking little by
little. I can do "Hide() / Show()" to hide the shirnking scrollbar
but it still takes 3 seconds to complete.
I think the DataGridView is drawing to display after each column
resize, when I only want it to set the widths and draw at the end. Is
there a way to do this? Is "SuspendLayout()" suppose to do this?

NB- Hide quoted text -

- Show quoted text -

I have thousands of rows in my table. It does go faster if there are
less rows in my table. The 3 second wait isn't bad for me; I was just
thinking that it was strange to be able to see the bottom scroll bar
shrink little by little, which threw me off (thinking that maybe it
can go faster if it didn't reset the size of the scroll constantly
(maybe its drawing to display constantly aswell) - Thinking "Why arn't
you just doing it once at the end after all the widths are set!" Kind
of thing).

Thanks for the reply :)

NB
 
Back
Top