Infragistics2.Win.UltraWinListView.v8.1
ColumnAutoSizeMode Property
See Also  Example
Infragistics.Win.UltraWinListView Namespace > UltraListViewDetailsSettings Class : ColumnAutoSizeMode Property

Gets/sets whether the width of the columns displayed by the control is automatically made large enough to display all item/sub-item values when the end user double-clicks on the header.

Syntax

Visual Basic (Declaration) 
Public Property ColumnAutoSizeMode As ColumnAutoSizeMode
C# 
public ColumnAutoSizeMode ColumnAutoSizeMode {get; set;}

Remarks

Note: The ColumnAutoSizeMode property is only applicable when the UltraListView.View property is set to 'Details'.

Note: If the value of a column's UltraListViewColumnBase.AllowSizing property resolves to false, and sizing via the user interface for the column is disallowed, the ColumnAutoSizeMode property resolves to 'None', and that column cannot be auto-sized via the user interface.

The ColumnAutoSizeMode property affects all columns displayed by the control; to set the auto-sizing mode for a particular column, use the UltraListViewColumnBase.AutoSizeMode property.

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:

Visual BasicCopy Code
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
C#Copy Code
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;

    

See Also