'宣言 Public Class BeforeRowLayoutItemResizedEventArgs Inherits System.ComponentModel.CancelEventArgs
public class BeforeRowLayoutItemResizedEventArgs : System.ComponentModel.CancelEventArgs
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.UltraWinGrid Private Sub UltraGrid1_BeforeRowLayoutItemResized(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeRowLayoutItemResizedEventArgs) Handles UltraGrid1.BeforeRowLayoutItemResized Debug.Write("BeforeRowLayoutItemResized: ") If TypeOf e.RowLayoutItem Is UltraGridColumn Then ' If the RowLayoutItem is an instance of UltraGridColumn, then cells associated ' with that column are being resized. Dim column As UltraGridColumn = DirectCast(e.RowLayoutItem, UltraGridColumn) Debug.Write("Cell in row-layout resized. Column = " & column.Header.Caption) Else ' If the RowLayoutItem is an instance of HeaderBase, then column header (also ' referred to as column label) is being resized. Dim header As HeaderBase = DirectCast(e.RowLayoutItem, HeaderBase) Debug.Write("Header in row-layout resized. Header = " & header.Caption) End If Debug.WriteLine(" Old Size = " & e.OldSize.ToString() & " New Size = " & e.NewSize.ToString()) ' You can conditionally cancel the resize operation by setting Cancel to true. If e.OldSize.Height <> e.NewSize.Height Then e.Cancel = True ElseIf (e.NewSize.Width > 200) Then ' You can also set the NewSize to impose constraints on how the item can be resized. ' In this case we will prevent the user from resizing items greater than 200. e.NewSize = New Size(200, e.NewSize.Height) End If End Sub Private Sub UltraGrid1_AfterRowLayoutItemResized(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.AfterRowLayoutItemResizedEventArgs) Handles UltraGrid1.AfterRowLayoutItemResized Debug.Write("AfterRowLayoutItemResized: ") If TypeOf e.RowLayoutItem Is UltraGridColumn Then ' If the RowLayoutItem is an instance of UltraGridColumn, then cells associated ' with that column are being resized. Dim column As UltraGridColumn = DirectCast(e.RowLayoutItem, UltraGridColumn) Debug.Write("Cell in row-layout resized. Column = " & column.Header.Caption) Else ' If the RowLayoutItem is an instance of HeaderBase, then column header (also ' referred to as column label) is being resized. Dim header As HeaderBase = DirectCast(e.RowLayoutItem, HeaderBase) Debug.Write("Header in row-layout resized. Header = " & header.Caption) End If Debug.WriteLine(" New Size = " & e.RowLayoutItem.PreferredSize.ToString()) End Sub
using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using System.Diagnostics; private void ultraGrid1_BeforeRowLayoutItemResized(object sender, Infragistics.Win.UltraWinGrid.BeforeRowLayoutItemResizedEventArgs e) { Debug.Write( "BeforeRowLayoutItemResized: " ); if ( e.RowLayoutItem is UltraGridColumn ) { // If the RowLayoutItem is an instance of UltraGridColumn, then cells associated // with that column are being resized. UltraGridColumn column = (UltraGridColumn)e.RowLayoutItem; Debug.Write( "Cell in row-layout resized. Column = " + column.Header.Caption ); } else { // If the RowLayoutItem is an instance of HeaderBase, then column header (also // referred to as column label) is being resized. HeaderBase header = (HeaderBase)e.RowLayoutItem; Debug.Write( "Header in row-layout resized. Header = " + header.Caption ); } Debug.WriteLine( " Old Size = " + e.OldSize.ToString( ) + " New Size = " + e.NewSize ); // You can conditionally cancel the resize operation by setting Cancel to true. if ( e.OldSize.Height != e.NewSize.Height ) { e.Cancel = true; } // You can also set the NewSize to impose constraints on how the item can be resized. // In this case we will prevent the user from resizing items greater than 200. else if ( e.NewSize.Width > 200 ) { e.NewSize = new Size( 200, e.NewSize.Height ); } } private void ultraGrid1_AfterRowLayoutItemResized(object sender, Infragistics.Win.UltraWinGrid.AfterRowLayoutItemResizedEventArgs e) { Debug.Write( "AfterRowLayoutItemResized: " ); if ( e.RowLayoutItem is UltraGridColumn ) { // If the RowLayoutItem is an instance of UltraGridColumn, then cells associated // with that column are being resized. UltraGridColumn column = (UltraGridColumn)e.RowLayoutItem; Debug.Write( "Cell in row-layout resized. Column = " + column.Header.Caption ); } else { // If the RowLayoutItem is an instance of HeaderBase, then column header (also // referred to as column label) is being resized. HeaderBase header = (HeaderBase)e.RowLayoutItem; Debug.Write( "Header in row-layout resized. Header = " + header.Caption ); } Debug.WriteLine( " New Size = " + e.RowLayoutItem.PreferredSize.ToString( ) ); }