TreeList.BeforeFocusNode Event

Fires before a node is focused.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v20.1.dll

Declaration

public event BeforeFocusNodeEventHandler BeforeFocusNode
Public Event BeforeFocusNode As BeforeFocusNodeEventHandler

Event Data

The BeforeFocusNode event's data class is BeforeFocusNodeEventArgs. The following properties provide information specific to this event:

Property Description
CanFocus Gets or sets a value indicating whether focus is allowed to be moved.
Node Gets the current Tree List node. Inherited from NodeEventArgs.
OldNode Gets the previously focused Tree List node. Inherited from FocusedNodeChangedEventArgs.

Remarks

The BeforeFocusNode event is raised each time a node is about to lose focus. The previously and currently focused nodes can be identified by the event parameter's NodeEventArgs.Node and FocusedNodeChangedEventArgs.OldNode properties, respectively. The BeforeFocusNodeEventArgs.CanFocus property specifies whether the node can be focused. To prevent node focus changing, set this property to false.

Once the focused node has been changed, the TreeList.FocusedNodeChanged and TreeList.AfterFocusNode events are raised.

Examples

The following example prohibits focusing the first node within the control, by handling the TreeList.BeforeFocusNode event.

private void treeList1_BeforeFocusNode(object sender, 
DevExpress.XtraTreeList.BeforeFocusNodeEventArgs e) {
   if (e.Node.Id == (sender as TreeList).Nodes[0].Id) 
      e.CanFocus = false;
}
See Also