Version

BeforeNodeLayoutItemResize Event

Occurs before a node layout item (i.e., a column header or cell) is resized by the end user.
Syntax
'Declaration
 
Public Event BeforeNodeLayoutItemResize As BeforeNodeLayoutItemResizeEventHandler
public event BeforeNodeLayoutItemResizeEventHandler BeforeNodeLayoutItemResize
Event Data

The event handler receives an argument of type BeforeNodeLayoutItemResizeEventArgs containing data related to this event. The following BeforeNodeLayoutItemResizeEventArgs properties provide information specific to this event.

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
Cell Returns the UltraTreeNodeCell that was resized.
Column Returns the UltraTreeNodeColumn that was resized.
IsAutoResize Returns a boolean value indicating whether the event was triggered by an auto-resize operation.
IsCell Returns whether the item that was resized represents a cell.
IsLabel Returns whether the item that was resized represents a column header (otherwise referred to as label).
NewSize Gets/sets the new size for the node layout item.
Node Returns the UltraTreeNode which defines the cell that is being resized.
OriginalSize Returns the size of the node layout item before the user changed it.
Example
The following code sample demonstrates how to use the BeforeNodeLayoutItemResize and AfterNodeLayoutItemResize events.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Imports Infragistics.Win
Imports Infragistics.Win.Layout
Imports Infragistics.Win.UltraWinTree

    Private Sub ultraTree1_AfterNodeLayoutItemResize(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTree.AfterNodeLayoutItemResizeEventArgs) Handles ultraTree1.AfterNodeLayoutItemResize

        '	Output a message to the debug window describing the resize operation
        Dim message As String = String.Empty
        If (e.IsCell) Then
            message = "Cell '" + e.Cell.Text + "' was successfully resized."
        Else
            message = "The header of column '" + e.Column.TextResolved + "' was successfully resized."
        End If

    End Sub

    Private Sub ultraTree1_BeforeNodeLayoutItemResize(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTree.BeforeNodeLayoutItemResizeEventArgs) Handles ultraTree1.BeforeNodeLayoutItemResize
        '	Disallow cell resizing for non-root level nodes
        If Not e.Node Is Nothing AndAlso e.Node.Level > 0 Then

            e.Cancel = True
            Return
        End If

        Dim originalSize As Size = Size.Empty

        '	Determine whether a cell or header was resized
        If (e.IsLabel) Then
            originalSize = e.Column.LayoutInfo.PreferredLabelSize
        Else
            originalSize = e.Column.LayoutInfo.PreferredCellSize
        End If

        '	Determine the amount by which the item was resized
        Dim delta As Size = New Size(e.NewSize.Width - originalSize.Width, e.NewSize.Height - originalSize.Height)

        '	Output a message to the debug window describing the resize operation
        Dim message As String = String.Empty
        If (e.IsCell) Then
            message = "Cell '" + e.Cell.Text + "' is being resized by " + delta.Width.ToString() + " units horizontally and " + delta.Height.ToString() + " units vertically."
        Else
            message = "The header of column '" + e.Column.TextResolved + "' is being resized by " + delta.Width.ToString() + " units horizontally and " + delta.Height.ToString() + " units vertically."
        End If

        Debug.WriteLine(message)

    End Sub
using Infragistics.Win;
using Infragistics.Win.Layout;
using Infragistics.Win.UltraWinTree;
using System.Diagnostics;

		private void ultraTree1_AfterNodeLayoutItemResize(object sender, Infragistics.Win.UltraWinTree.AfterNodeLayoutItemResizeEventArgs e)
		{
			//	Output a message to the debug window describing the resize operation
			string message = string.Empty;
			if ( e.IsCell )
				message = "Cell '" + e.Cell.Text + "' was successfully resized.";
			else
				message = "The header of column '" + e.Column.TextResolved + "' was successfully resized.";
		}

		private void ultraTree1_BeforeNodeLayoutItemResize(object sender, Infragistics.Win.UltraWinTree.BeforeNodeLayoutItemResizeEventArgs e)
		{
			//	Disallow cell resizing for non-root level nodes
			if ( e.Node != null && e.Node.Level > 0 )
			{
				e.Cancel = true;
				return;
			}

			Size originalSize = Size.Empty;

			//	Determine whether a cell or header was resized
			if ( e.IsLabel )
				originalSize = e.Column.LayoutInfo.PreferredLabelSize;
			else
				originalSize = e.Column.LayoutInfo.PreferredCellSize;

			//	Determine the amount by which the item was resized
			Size delta = new Size(	e.NewSize.Width - originalSize.Width,
									e.NewSize.Height - originalSize.Height );

			//	Output a message to the debug window describing the resize operation
			string message = string.Empty;
			if ( e.IsCell )
				message = "Cell '" + e.Cell.Text + "' is being resized by " + delta.Width.ToString() + " units horizontally and " + delta.Height.ToString() + " units vertically.";
			else
				message = "The header of column '" + e.Column.TextResolved + "' is being resized by " + delta.Width.ToString() + " units horizontally and " + delta.Height.ToString() + " units vertically.";

			Debug.WriteLine( message );
		}
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