ListView::AutoResizeColumn Method (Int32, ColumnHeaderAutoResizeStyle)
.NET Framework (current version)
Resizes the width of the given column as indicated by the resize style.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
public: void AutoResizeColumn( int columnIndex, ColumnHeaderAutoResizeStyle headerAutoResize )
Parameters
- columnIndex
-
Type:
System::Int32
The zero-based index of the column to resize.
- headerAutoResize
-
Type:
System.Windows.Forms::ColumnHeaderAutoResizeStyle
One of the ColumnHeaderAutoResizeStyle values.
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException | columnIndex is greater than 0 when Columns is null -or- columnIndex is less than 0 or greater than the number of columns set. |
| InvalidEnumArgumentException | headerAutoResize is not a member of the ColumnHeaderAutoResizeStyle enumeration. |
The following code example demonstrates initializing a ListView in detail view and automatically resizing the columns using the AutoResizeColumn method. To run this example, paste this code into a Windows Form and call the InitializeResizingListView method from the form's constructor or Load event handler.
.NET Framework
Available since 2.0
Available since 2.0
Show: