You will typically call the programmatic resizing methods at specific times. It is also useful to provide initial sizes for user-resizable rows, columns, and headers, and for column fill mode.
Use content-based automatic resizing with caution when working with large amounts of data.
The value of this property is based on the column's Auto Size Mode property value unless that value is Not Set, in which case the control's Auto Size Columns Mode value is inherited.
You must then call the Auto Resize Columns method to adjust the column widths to the calculated ideal.
For example, if you call the Auto Resize Rows(Data Grid View Auto Size Rows Mode, Boolean) overload of the Auto Resize Rows method and pass in a value of false for the Boolean parameter, the overload will calculate the ideal heights and widths for cells in the row, but it will adjust the row heights only.
For example, if a column is hidden after it is automatically sized to fit a large cell value, the hidden column will not change its size if the row containing the large cell value is deleted.
Content-based automatic sizing modes do not affect rows, columns, or headers that you have hidden by setting the row or column Visible property or the control Row Headers Visible or Column Headers Visible properties to false.
You can also configure rows, columns, and headers to automatically adjust their sizes to fit their cell contents.
For more information about this mode, see the Column Fill Mode section below.
Programmatic content-based resizing affects rows, columns, and headers regardless of their visibility.
Automatic sizing does not occur when visibility changes, so changing the column Visible property back to true will not force it to recalculate its size based on its current contents.
If you configure both rows and columns for content-based automatic sizing and Wrap Mode is enabled, the Data Grid View control will adjust sizes whenever cell contents changed and will use an ideal cell height-to-width ratio when calculating new sizes.