如何在 DevExpress WPF TreeListControl 中获得焦点或选定的值?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12819913/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 05:43:12 来源:igfitidea点击:
How to get focused or selected value in DevExpress WPF TreeListControl?
提问by loki
I am using DevExpress TreeListControl:
我正在使用 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?
如何获取选定的行值?
回答by DmitryG
It is not needed to use reflection at all. You can use the TreeListView.FocusedNodeproperty and the TreeListView.GetNodeValuemethod:
根本不需要使用反射。您可以使用TreeListView.FocusedNode属性和TreeListView.GetNodeValue方法:
object id = treeListView.GetNodeValue(treeListView.FocusedNode,"Id");

