Version

OnBeforeCut Method

Called before nodes are cut to the clipboard.
Syntax
'Declaration
 
Protected Overridable Sub OnBeforeCut( _
   ByVal e As BeforeCutEventArgs _
) 
protected virtual void OnBeforeCut( 
   BeforeCutEventArgs e
)

Parameters

e
An System.EventArgs that contains the event data.
Example
The following sample code illustrates some of the information available in the BeforeCut event.

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.UltraWinTree

Private Sub ultraTree1_BeforeCut(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTree.BeforeCutEventArgs) Handles ultraTree1.BeforeCut

    Dim sb As New System.Text.StringBuilder()
    Dim node As UltraTreeNode
    Dim dr As DialogResult

    ' Setting the Tag of the Nodes collection passed into the BeforeCut
    ' and BeforeCopy events to some serializable value can be used to
    ' identify the tree that copied the nodes to the clipboard. This Tag
    ' value will be de-serialized and set on the Nodes collection that is
    ' passed into the BeforePaste event. This can be used for preventing 
    ' paste operations between trees.

    ' Set the Tag property on the Nodes collection to the tree's hash code.
    ' Note: don't set the tag to the tree itself since that isn't serializable
    e.Nodes.Tag = Me.ultraTree1.GetHashCode()

    sb.Append("The following nodes are about to be cut to the clipboard: ")

    ' Loop over the nodes that will be cut to the clipboard.
    ' Note: The Nodes collection exposed by the event args
    ' is read-only.
    For Each node In e.Nodes
        sb.Append(node.Text)
        sb.Append(", ")
    Next

    sb.Append(" Press ''OK'' or ''Cancel''.")

    dr = MessageBox.Show(Me, sb.ToString(), "Cutting nodes to the clipboard", MessageBoxButtons.OKCancel)

    If dr = DialogResult.Cancel Then
        e.Cancel = True
    End If

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

private void ultraTree1_BeforeCut(object sender, Infragistics.Win.UltraWinTree.BeforeCutEventArgs e)
{
	// Setting the Tag of the Nodes collection passed into the BeforeCut
	// and BeforeCopy events to some serializable value can be used to
	// identify the tree that copied the nodes to the clipboard. This Tag
	// value will be de-serialized and set on the Nodes collection that is
	// passed into the BeforePaste event. This can be used for preventing 
	// paste operations between trees.

	// Set the Tag property on the Nodes collection to the tree's hash code.
	// Note: don't set the tag to the tree itself since that isn't serializable
	e.Nodes.Tag = this.ultraTree1.GetHashCode();

	System.Text.StringBuilder sb = new System.Text.StringBuilder();

	sb.Append("The following nodes are about to be cut to the clipboard: ");

	// Loop over the nodes that will be cut to the clipboard.
	// Note: The Nodes collection exposed by the event args
	// is read-only.
	foreach ( UltraTreeNode node in e.Nodes )
	{
		sb.Append( node.Text );
		sb.Append( ", " );
	}

	sb.Append(" Press ''OK'' or ''Cancel''.");

	DialogResult dr = MessageBox.Show( this,
					  sb.ToString(),
					  "Cutting nodes to the clipboard",
					  MessageBoxButtons.OKCancel );

	if ( dr == DialogResult.Cancel )
		e.Cancel = true;
		
}
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