How can I add an event handler for when a Devexpress TreeList
selection changes? Here's what I have that isn't working:
window.nList.SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(nList_SelectedItemChanged);
private void nList_SelectedItemChanged(object sender, DevExpress.Xpf.Grid.SelectedItemChangedEventArgs e)
{
System.Diagnostics.Debug.WriteLine(nList.CurrentCellValue);
}
Just use TreeListControl.SelectionChanged
event.
In XAML
:
<dxg:TreeListControl x:Name="treeListControl1" SelectedItemChanged="treeListControl1_SelectedItemChanged" />
Or in c#
:
treeListControl1.SelectedItemChanged += treeListControl1_SelectedItemChanged;
Event handler method:
void treeListControl1_SelectedItemChanged(object sender, SelectedItemChangedEventArgs e)
{
MessageBox.Show(((YourClass)e.NewItem).SomeValue.ToString());
}
Are you using the multi-select mode? The SelectedItemChanged and SelectionChanged events aren't fired if the SelectionMode property is set to MultiSelectMode.None
(default value).
Please use the CurrentItemChanged event instead when single-selection mode is active. This event occurs after the focused row has been changed (eg row focus moves to another data row).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.