C datagridview cellvalidating event
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 maximum performance, use programmatic resizing instead so that you can resize at specific times, such as immediately after new data is loaded.
It is also useful to provide initial sizes for user-resizable rows, columns, and headers, and for column fill mode. The new sizes are automatically calculated to display all cell contents without clipping. When automatic sizing is disabled, you can programmatically set the exact width or height of rows, columns, or headers through the following properties: These methods will resize rows, columns, or headers once rather than configuring them for continuous resizing. Because Not Set restores the value inheritance, the Resizable property will never return a Not Set value unless the row or column has not been added to a Data Grid View control. Set Resizable to Not Set to restore the inheritance.