Start Cellvalidating datagridview example

Cellvalidating datagridview example

For maximum performance, use programmatic resizing instead so that you can resize at specific times, such as immediately after new data is loaded.

Column fill mode causes the visible columns in the control to fill the width of the control's display area.

There are two kinds of automatic sizing in the Data Grid View control: column fill mode and content-based automatic sizing.

Note: If you maintain cell values in a custom data cache using virtual mode, automatic sizing occurs when the user edits a cell value but does not occur when you alter a cached value outside of a Cell Value Pushed event handler.

In this case, size adjustment occurs whenever cell contents change.

Programmatic resizing is useful to avoid performance penalties with continuous resizing.

When you programmatically resize columns that have Inherited Auto Size Mode property values of Fill, however, the calculated content-based widths are used to proportionally adjust the column Fill Weight property values, and the actually column widths are then calculated according to these new proportions so that all columns fill the available display area of the control.

If the State value includes the Resizable Set flag, the Resizable property value is not inherited.