WinForm control DataGridView. autoSizeColumnsMode Property
Change the AutoSizeMode of the DataGridView column
Allcells adjusts the column width to fit the contents of all the cells in the column, including the header cell.
Allcellsexceptheader adjusts the column width to fit the contents of all cells in the column, excluding header cells.
ColumnHeader adjusts the column width to fit the contents of the column header cell.
Displayedcells adjusts the column width to fit the contents of all the cells in the column that are displayed on the current screen, including the header cell.
Displayedcellsexceptheader adjusts the column width to fit the contents of all the cells in the column of the row displayed on the current screen, excluding header cells.
Fill adjusts the column width so that the width of all columns fills the display area of the control exactly, and only horizontal scrolling is required to ensure that the column width is above the Datagridviewcolumn.minimumwidth property value. The relative column width is determined by the relative Datagridviewcolumn.fillweight property value.
None The column width is not automatically adjusted.
The resizing behavior of the NotSet column is inherited from the Datagridview.autosizecolumnsmode property.
WinForm Datagridview.autosizecolumnsmode Properties