How to get focused or selected value in DevExpress WPF TreeListControl?

5.6k Views Asked by At

I am using DevExpress TreeListControl:

void TreeListView_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e) {
    string val;
    PropertyInfo[] properties =  e.NewRow.GetType().GetProperties();
    foreach (PropertyInfo item in properties) {
        string x =  item.Name;
        if (x == "Id") {
            var barProperty = item.GetType().GetProperty("Id");
            if (barProperty != null) {
                object[] obj = new Object[0];
                val = item.GetValue(sender, obj) as string;
            }
        }
    }
}

How to get selected row value?

1

There are 1 best solutions below

0
On BEST ANSWER

It is not needed to use reflection at all. You can use the TreeListView.FocusedNode property and the TreeListView.GetNodeValue method:

object id = treeListView.GetNodeValue(treeListView.FocusedNode,"Id");