'Declaration Public Event ColumnResized As ColumnResizedEventHandler
public event ColumnResizedEventHandler ColumnResized
The event handler receives an argument of type ColumnResizedEventArgs containing data related to this event. The following ColumnResizedEventArgs properties provide information specific to this event.
Property | Description |
---|---|
Cancel (Inherited from System.ComponentModel.CancelEventArgs) | |
Column (Inherited from Infragistics.Win.UltraWinListView.CancelableColumnEventArgs) | Returns the UltraListViewColumnBase with which this instance is associated. |
Unlike the ColumnResizing event, which only fires as a result of user interaction, the ColumnResized event also fires when the Width property has been changed programmatically.
Imports Infragistics.Win Imports Infragistics.Win.UltraWinListView Private Sub ultraListView1_ColumnResizing(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinListView.ColumnResizingEventArgs) Handles ultraListView1.ColumnResizing ' If the column about to be resized is the MainColumn, cancel ' the event to prevent the column from being resized. If (e.Column.GetType() Is GetType(UltraListViewMainColumn)) Then e.Cancel = True End Sub Private Sub ultraListView1_ColumnResized(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinListView.ColumnResizedEventArgs) Handles ultraListView1.ColumnResized Dim listView As UltraListView = CType(sender, UltraListView) ' Get a rectangle which describes the client area ' of the control, so we can determine the width ' minus the width of the vertical scrollbar, if ' one is present. Dim displayRect As Rectangle = listView.DisplayRectangle Dim clientWidth As Integer = displayRect.Width ' Subtract out the width of the MainColumn Dim mainColumnWidth As Integer = IIf(listView.MainColumn.Width > 0, listView.MainColumn.Width, 200) clientWidth -= mainColumnWidth ' Iterate the SubItemColumns collection to get the number of ' visible columns. Dim visibleByDefault As Boolean = listView.ViewSettingsDetails.SubItemColumnsVisibleByDefault Dim visibleColumnsCount As Integer = 0 Dim subItemColumn As UltraListViewSubItemColumn For Each subItemColumn In listView.SubItemColumns If (subItemColumn.VisibleInDetailsView = DefaultableBoolean.True Or _ (visibleByDefault AndAlso subItemColumn.VisibleInDetailsView = DefaultableBoolean.Default)) Then visibleColumnsCount += 1 End If Next ' Iterate the SubItemColumns collection and set the width For Each subItemColumn In listView.SubItemColumns subItemColumn.Width = Math.Floor((clientWidth / visibleColumnsCount)) Next End Sub
using Infragistics.Win; using Infragistics.Win.UltraWinListView; using System.Diagnostics; private void ultraListView1_ColumnResizing(object sender, Infragistics.Win.UltraWinListView.ColumnResizingEventArgs e) { // If the column about to be resized is the MainColumn, cancel // the event to prevent the column from being resized. if ( e.Column is UltraListViewMainColumn ) e.Cancel = true; } private void ultraListView1_ColumnResized(object sender, Infragistics.Win.UltraWinListView.ColumnResizedEventArgs e) { UltraListView listView = sender as UltraListView; // Get a rectangle which describes the client area // of the control, so we can determine the width // minus the width of the vertical scrollbar, if // one is present. Rectangle displayRect = listView.DisplayRectangle; int clientWidth = displayRect.Width; // Subtract out the width of the MainColumn clientWidth -= listView.MainColumn.Width > 0 ? listView.MainColumn.Width : 200; // Iterate the SubItemColumns collection to get the number of // visible columns. bool visibleByDefault = listView.ViewSettingsDetails.SubItemColumnsVisibleByDefault; int visibleColumnsCount = 0; foreach( UltraListViewSubItemColumn subItemColumn in listView.SubItemColumns ) { bool visible = subItemColumn.VisibleInDetailsView == DefaultableBoolean.True || (visibleByDefault && subItemColumn.VisibleInDetailsView == DefaultableBoolean.Default); if ( visible ) visibleColumnsCount++; } // Iterate the SubItemColumns collection and set the width foreach( UltraListViewSubItemColumn subItemColumn in listView.SubItemColumns ) { subItemColumn.Width = (int)(clientWidth / visibleColumnsCount); } } }
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