excel表格treeview中的子节点与父节点处于同一级别

我希望有人能帮助我,因为我一直坚持了好几天。

我有一个工作表,我想在树视图中可视化。 因为这是我的第一个问题,我的名声还不够高,所以图片是以链接的forms提供的。 img的工作表来可视化

'i:loop through objects 'j:loop through object childs 'counter: keep track of how many childs processed For i = 1 To 5 Set parentCell = rng.Offset(counter, 0) 'parent values strParent = parentCell.Value 'parent values ' Build the treeview for both the Left and the right side of the screen trvLeft.Nodes.Add Key:=strParent, Text:=strParent trvRight.Nodes.Add Key:=strParent, Text:=strParent For j = 1 To HelperMethods.AmountInEntity 'can be any number strPresent = rng.Offset(counter, 6).Value '"x" or "" 'Add to left treeview Call trvLeft.Nodes.Add(Relative:=strParent, Relationship:=tvwChild, Key:=rng.Offset(counter, 4).Value, Text:=rng.Offset(counter, 4).Value) 'add to right treeview. If not present, mark as red. If strPresent = "x" The Call trvRight.Nodes.Add(Relative:=strParent, Relationship:=tvwChild, Key:=rng.Offset(counter, 5).Value, Text:=rng.Offset(counter, 5).Value) Else With trvRight.Nodes.Add(strParent, tvwChild, rng.Offset(counter, 5).Value, rng.Offset(counter, 5).Value) .ForeColor = vbRed End With End If counter = counter + 1 Next j Next i 

将节点添加到其父节点时出错,因为所有节点都在同一级别上创build。

我注意到的一件奇怪的事情是,父母被添加到列表的底部,而孩子被添加到顶部。 img平坦的树

提前致谢,

菲利普

我已经删除了树视图,并做了新的。 不要问我如何,但现在它工作。 Microsoft Excel的奇迹…

-编辑-

错误再次发生,所以它不是孤立的事件。 有没有人有任何想法可能会导致这种行为?