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 に答える