Skip to main content
A newer version of this page is available. .
Tab

TreeViewNodeCancelEventArgs.Cancel Property

Gets or sets a value indicating whether the action that raised the event should be canceled.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

public bool Cancel { get; set; }

Property Value

Type Description
Boolean

true if the action that raised the event should be canceled; otherwise, false.

Remarks

The TreeViewNodeCancelEventArgs object is passed to the events that fire before specific actions. The Cancel property of this object enables you to cancel the action which is about to be performed. Set this property to true to cancel the action that raised the event. This can be used if you want to prohibit performing the corresponding action with respect to specific conditions.

Example

The sample code below represents an ASPxTreeView.ExpandedChanging event handler. The event handler prevents collapsing nodes if it has selected children in any generation.

using DevExpress.Web.ASPxTreeView;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ASPxTreeView1_ExpandedChanging(object source, DevExpress.Web.ASPxTreeView.TreeViewNodeCancelEventArgs e) {
        if ((e.Node.Expanded) && (ASPxTreeView1.SelectedNode != null)) {
            TreeViewNode  node = ASPxTreeView1.SelectedNode.Parent;
            while (node != null) {
                if (e.Node == node) {
                    e.Cancel = true;
                    break;
                }
                node = node.Parent;
            }
        }
    }
}
See Also