我正在使用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;
}
}
}
}
如何获取选定的行值?
答案 0 :(得分:2)
根本不需要使用反射。您可以使用TreeListView.FocusedNode属性和TreeListView.GetNodeValue方法:
object id = treeListView.GetNodeValue(treeListView.FocusedNode,"Id");