1

我正在使用 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;
            }
        }
    }
}

如何获取选定的行值?

4

1 回答 1

2

根本不需要使用反射。您可以使用TreeListView.FocusedNode属性和TreeListView.GetNodeValue方法:

object id = treeListView.GetNodeValue(treeListView.FocusedNode,"Id");
于 2012-10-10T14:40:39.247 回答