Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TreeList.SelectionChanged Event

Fires when node selection is changed. In v21.1 and higher, the event fires both in single and multiple node selection modes.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v24.2.dll

NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.TreeList

#Declaration

[DXCategory("Property Changed")]
public event EventHandler SelectionChanged

#Event Data

The SelectionChanged event's data class is EventArgs.

#Remarks

#Single Row Selection (treeList.OptionsSelection.MultiSelect option is false)

In v21.1 and higher, the following two events fire one after another when a row (node) is focused (selected):

You can handle these events interchangeably to respond to node selection changes.

In versions prior to v21.1, the SelectionChanged event does not fire when a node receives focus.

#Multiple Row Selection (treeList.OptionsSelection.MultiSelect option is true)

The SelectionChanged event fires every time a node is selected or deselected. Use the TreeList.Selection property to identify currently selected nodes.

#Example

The following sample code displays the number of currently selected nodes in a status bar. The TreeList.SelectionChanged event is used to respond to changing the selection.

Selections - Changed

using DevExpress.XtraTreeList;

private void treeList1_SelectionChanged(object sender, EventArgs e) {
    string s = (sender as TreeList).Selection.Count.ToString() + " node(s) selected";
    barStaticItem1.Caption = s;
}
See Also