windowsforms-devexpress-dot-xtratreelist-dot-treelist-56c8bbe0.md
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.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList
[DXCategory("Property Changed")]
public event EventHandler SelectionChanged
<DXCategory("Property Changed")>
Public Event SelectionChanged As EventHandler
The SelectionChanged event's data class is EventArgs.
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.
The SelectionChanged event fires every time a node is selected or deselected. Use the TreeList.Selection property to identify currently selected nodes.
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.
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;
}
Imports DevExpress.XtraTreeList
Private Sub TreeList1_SelectionChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles TreeList1.SelectionChanged
Dim s As String = sender.Selection.Count.ToString() + " node(s) selected"
barStaticItem1.Caption = s
End Sub
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SelectionChanged event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
xaf-win-gantt-control/CS/XPO/GanttSolutionXPO/GanttSolutionXPO.Win/Editors/CustomGanttEditor.cs#L89
control.OptionsCustomization.AllowModifyProgress = DevExpress.Utils.DefaultBoolean.True;
control.SelectionChanged += Control_SelectedIndexChanged;
control.FocusedNodeChanged += Control_FocusedNodeChanged;
See Also