TreeList.BeforeCheckNode Event

Occurs before a node's check state is changed.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v20.1.dll

Declaration

public event CheckNodeEventHandler BeforeCheckNode
Public Event BeforeCheckNode As CheckNodeEventHandler

Event Data

The BeforeCheckNode event's data class is DevExpress.XtraTreeList.CheckNodeEventArgs.

Remarks

The BeforeCheckNode event is raised when an end-user changes a node's check state, and allows you to cancel the operation or specify the required check state.

To cancel the operation, set the event parameter's CanCheck property to false. The previous and current node states are returned by the PrevState and State properties, respectively. You can change the State property's value to specify the required node state.

The following code prevents an end-user from setting nodes to an indeterminate state.


private void treeList1_BeforeCheckNode(object sender, DevExpress.XtraTreeList.CheckNodeEventArgs e) {
    if (e.State == CheckState.Indeterminate)
        e.State = (e.PrevState == CheckState.Checked ? CheckState.Unchecked : CheckState.Checked);
}

After a node's state has been changed, the TreeList.AfterCheckNode event is raised.

See Node Checking - Checkboxes and Radio Buttons to learn more.

See Also