Clearing a Formatted DataGridView

When I try to clear controls and DataviewGrid from a panel which has bound data, it takes several seconds to do it, when I have this line

GridHandle.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells

If Comment this line then it clears fast. If comment the above line then it clears faster.

Any help would be appreciated.
Khalid Mirza
mirza@Stellex.com

[576 byte] By [KhalidMirza] at [2008-2-28]
# 1
Any changes done to the DataGridView's content -- removing rows for example causes the grid to recompute autosize mode. Depending upon the number of rows this can take more time. It is a good idea when you know that you are going to perform a large update and you are using an autosize mode, to set the AutoSizeColumnsMode to None, do the large update, then reset the AutoSizeColumnsMode back to AllCells.

Hope this helps,
-mark
DataGridView Program Manager
Microsoft
This post is provided "as-is"

MarkRideout at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...