Version

PerformAutoResize(ColumnAutoSizeMode) Method

Sets the Width of this column to the value required to fully display the header text and/or the text for the affected items/sub-items, as specified by the value of the autoSizeMode parameter.
Syntax
'Declaration
 
Public Overloads Sub PerformAutoResize( _
   ByVal autoSizeMode As ColumnAutoSizeMode _
) 
public void PerformAutoResize( 
   ColumnAutoSizeMode autoSizeMode
)

Parameters

autoSizeMode
ColumnAutoSizeMode constant which determines whether the text for all items, or only that of items that are currently on-screen, are used when determining the new width for the column.
Remarks

When 'AllItems' is specified as the value of the autoSizeMode parameter, all members of the associated UltraListView control's Items collection are evaluated when determining the new width for the column. When 'VisibleItems' is specified, only the items that are currently in the viewable area of the control are evaluated.

If this UltraListViewColumnBase instance is the MainColumn, the value of the item's UltraListViewItemBase.Text property is used; if this instance is an UltraListViewSubItemColumn, the value of the corresponding sub-item's Text property is used. The column's Width property is set to a value that is large enough to fully display the graphically widest value in the range.

In the case where the AutoFitColumns setting is enabled, and calling the PerformAutoResize method results in a width that cannot be honored because of constraints necessary in order to properly fit all columns, the automatically calculated width is negotiated to a value that allows the remaining columns to be displayed at their minimum width.

Note: Specifying a value of 'AllItems' for the autoSizeMode parameter can have performance ramifications in cases where there the Items collection contains a relatively large number of items.

Example
The following code sample demonstrates how to use the ColumnAutoSizeMode property of the UltraListViewDetailsSettings class, and the AutoSizeMode property of the UltraListViewColumnBase class, to enable the end user to easily resize the MainColumn's width to the size required to fully display both item and header text:

Imports Infragistics.Win
Imports Infragistics.Win.UltraWinListView

        '  Set the AutoSizeMode property of the MainColumn to 'VisibleItemsAndHeader',
        '  so that when the end user double-clicks the right edge of the header, the
        '  width of the column is adjusted so as to fully display the text of all
        '  visible items, as well as the header's caption.
        Me.ultraListView1.MainColumn.AutoSizeMode = ColumnAutoSizeMode.VisibleItemsAndHeader

        '  Call the PerformAutoResize method to programmatically resize the column
        Me.ultraListView1.MainColumn.PerformAutoResize(Me.ultraListView1.MainColumn.AutoSizeMode)

        '  Set the ColumnAutoSizeMode property of the UltraListViewDetailsSettings
        '  object (returned by the control's ViewSettingsDetails property) to a combination
        '  of the 'Header' and either 'VisibleItems' or 'AllItems' bits, depending on whether
        '  there are a relatively large number of items being displayed.
        Dim autoSizeMode As ColumnAutoSizeMode = ColumnAutoSizeMode.Header
        If (Me.ultraListView1.Items.Count >= LARGE_ITEM_COUNT) Then
            autoSizeMode = autoSizeMode Or ColumnAutoSizeMode.VisibleItems
        Else
            autoSizeMode = autoSizeMode Or ColumnAutoSizeMode.AllItems
        End If

        Me.ultraListView1.ViewSettingsDetails.ColumnAutoSizeMode = autoSizeMode
using Infragistics.Win;
using Infragistics.Win.UltraWinListView;

    //  Set the AutoSizeMode property of the MainColumn to 'VisibleItemsAndHeader',
    //  so that when the end user double-clicks the right edge of the header, the
    //  width of the column is adjusted so as to fully display the text of all
    //  visible items, as well as the header's caption.
    this.ultraListView1.MainColumn.AutoSizeMode = ColumnAutoSizeMode.VisibleItemsAndHeader;

    //  Call the PerformAutoResize method to programmatically resize the column
    this.ultraListView1.MainColumn.PerformAutoResize(this.ultraListView1.MainColumn.AutoSizeMode);

    //  Set the ColumnAutoSizeMode property of the UltraListViewDetailsSettings
    //  object (returned by the control's ViewSettingsDetails property) to a combination
    //  of the 'Header' and either 'VisibleItems' or 'AllItems' bits, depending on whether
    //  there are a relatively large number of items being displayed.
    ColumnAutoSizeMode autoSizeMode = ColumnAutoSizeMode.Header;
    if ( this.ultraListView1.Items.Count >= LARGE_ITEM_COUNT )
        autoSizeMode |= ColumnAutoSizeMode.VisibleItems;
    else
        autoSizeMode |= ColumnAutoSizeMode.AllItems;

    this.ultraListView1.ViewSettingsDetails.ColumnAutoSizeMode = autoSizeMode;
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also