ListView::AutoResizeColumns Method (ColumnHeaderAutoResizeStyle)

 

Resizes the width of the columns as indicated by the resize style.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public:
void AutoResizeColumns(
	ColumnHeaderAutoResizeStyle headerAutoResize
)

Parameters

headerAutoResize
Type: System.Windows.Forms::ColumnHeaderAutoResizeStyle

One of the ColumnHeaderAutoResizeStyle values.

Exception Condition
InvalidOperationException

AutoResizeColumn is called with a value other than None when View is not set to Details.

Calling this method is only effective once the ListView and containing Form have been constructed, and the ListView column headers and columns are populated with items. If new items are added to the ListView, the columns will not resize unless AutoResizeColumns is called again.

The following code example demonstrates initializing a ListView in detail view and automatically resizing the columns using the AutoResizeColumns method. To run this example, paste this code into a Windows Form and call the InitializeResizingListView2 method from the form's constructor or Load event handler.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: