Version

BeforeDelete Event

Occurs before UltraTreeNode objects are deleted.
Syntax
'Declaration
 
Public Event BeforeDelete As BeforeNodeDeleteChangedEventHandler
public event BeforeNodeDeleteChangedEventHandler BeforeDelete
Event Data

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

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
DisplayPromptMsg Determines whether or not to display the default message or dialog.
Nodes An array of the UltraTreeNode objects that will be deleted (read-only).
Remarks

Setting the System.ComponentModel.CancelEventArgs.Cancel property to true will prevent the UltraTreeNode from going into label edit mode.

The BeforeNodesDeletedEventArgs.Nodes property of the BeforeNodesDeletedEventArgs contains an array of the UltraTreeNode objects that are about to be deleted.

By default, the UltraTree will automatically display a confirmation dialog before Deleting nodes. To prevent this dialog from appearing, set the BeforeNodesDeletedEventArgs.DisplayPromptMsg property of the BeforeNodesDeletedEventArgs to false.

Example
The following sample code illustrates some of the information available in the BeforeDelete 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.UltraWinTree

Private Sub ultraTree1_BeforeDelete(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTree.BeforeNodesDeletedEventArgs) Handles ultraTree1.BeforeDelete

    Dim sb As New System.Text.StringBuilder()

    sb.Append("The following nodes are about to be deleted: ")

    Dim node As UltraTreeNode
    ' Loop over the nodes that are about to be deleted.
    ' Note: The Nodes collection exposed by the event args
    ' is read-only.
    For Each node In e.Nodes
        sb.Append(node.Key)
        sb.Append(", ")
    Next

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

    Dim dr As DialogResult

    dr = MessageBox.Show(Me, _
         sb.ToString(), _
         "Deleting Nodes", _
         MessageBoxButtons.OKCancel)

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

    ' Set the DisplayPromptMsg flag to false so the
    ' default messagebox will be suppressed.
    e.DisplayPromptMsg = False

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

private void ultraTree1_BeforeDelete(object sender, Infragistics.Win.UltraWinTree.BeforeNodesDeletedEventArgs e)
{

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

	sb.Append("The following nodes are about to be deleted: ");

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

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

	DialogResult dr = MessageBox.Show( this,
					  sb.ToString(),
					  "Deleting Nodes",
					  MessageBoxButtons.OKCancel );

	if ( dr == DialogResult.Cancel )
		e.Cancel = true;

	// Set the DisplayPromptMsg flag to false so the
	// default messagebox will be suppressed.
	e.DisplayPromptMsg = false;
		
}
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