【发布时间】:2015-07-28 17:45:28
【问题描述】:
我目前正在尝试使用 TreeListView,我想知道如何找到三层嵌套对象的值,其中层是位置,然后是系统,然后是设备。
private void initObjectListView()
{
// Can the given object be expanded?
this.treeListView1.CanExpandGetter = delegate(Object x)
{
return x is Location;
};
// What objects should belong underneath the given model object?
this.treeListView1.ChildrenGetter = delegate(Object x)
{
if (x is Location)
return ((Location)x).systemMap.Values;
throw new ArgumentException("Unknown TreeListView Object - Should a Location Type");
};
}
有一个并发字典systemMap(string,Device),其中字符串是设备的名称,设备本身就是一个设备对象。
我已经达到了如果我更换的地步
return ((Location)x).systemMap.Values;
与
return ((Location)x).systemMap["System 1"].deviceMap.Values;
我会为我想要的特定系统获得正确的 ListView,但显然我希望它对系统映射中的所有系统完成,而不是系统 1。
return ((Location)x).systemMap.Values;
只显示到位置,然后显示该位置下的系统,但不显示系统下的设备。
谢谢
【问题讨论】:
标签: c# winforms objectlistview