dotnetmonitor.com |
|
||||||||||||
| When automatic
sizing is disabled, you can programmatically set the exact width or height of
rows, columns, or headers through the following properties:
RowHeadersWidth ColumnHeadersHeight DataGridViewRow.Height DataGridViewColumn.Width
You can also programmatically resize rows, columns, and headers to fit their contents using the following methods:
AutoResizeColumn AutoResizeColumns AutoResizeColumnHeadersHeight AutoResizeRow AutoResizeRows AutoResizeRowHeadersWidth
These methods will resize rows, columns, or headers once rather than configuring them for continuous resizing. The new sizes are automatically calculated to display all cell contents without clipping. When you programmatically resize columns that have InheritedAutoSizeMode property values of Fill, however, the calculated content-based widths are used to proportionally adjust the column FillWeight 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.
Programmatic resizing is useful to avoid performance penalties with continuous resizing. It is also useful to provide initial sizes for user-resizable rows, columns, and headers, and for column fill mode.
You will typically call the programmatic resizing methods at specific times. For example, you might programmatically resize all columns immediately after loading data, or you might programmatically resize a specific row after a particular cell value has been modified. |
||||||||||||
|
||||||||||||