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.
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.
If content-based automatic sizing is enabled for one dimension only—that is, for rows but not columns, or for columns but not rows—and Wrap Mode is also enabled, size adjustment also occurs whenever the other dimension changes.