ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Treeview Control Populating Problem (https://www.excelbanter.com/excel-programming/343918-treeview-control-populating-problem.html)

misseill

Treeview Control Populating Problem
 
I am trying to populate a Treeview control with parent Plans and their
child Groups. I wrote code that should generate the following:

Plan 1
==Group 1
==Group 2
Plan 2
==Group 1
==Group 2
==Group 3
==Group 4
Plan 3
==Group 1
==Group 2
==Group 3
==Group 4
==Group 5

When the code runs, I only see the following in the treeview:

Plan 1
==Group 1
==Group 2
Plan 2
==Group 3
==Group 4
Plan 3
==Group 5

Here is my code. The variable "UBound(gPlanData(i).Group)" is 2, 4, 5
for each plan.

With Me.tvPlanGroup
For i = 1 To 3
Set nodX = .Nodes.Add(, , "Plan " & i, gPlanData(i).Name)
Set nodX = Nothing
y = UBound(gPlanData(i).Group)
For j = 1 To y
Set nodX = .Nodes.Add("Plan " & i, tvwChild, _
"Group " & j,
gPlanData(i).Group(j).Name)
nodX.EnsureVisible
Set nodX = Nothing
Next j
Next i
End With

If there are fewer groups for each subsequent plan, they don't show up
in the tree. This in code:
Plan 1
==Group 1
==Group 2
Plan 2
==Group 1
==Group 2
Plan 3
==Group 1
==Group 2

Shows in my tree as this:
Plan 1
==Group 1
==Group 2
Plan 2
Plan 3

Please help me figure out why this is behaving this way. Thanks in
advance, Erika.


misseill

Treeview Control Populating Problem
 
I figured it out. I had the same Key for my group names, so only new,
unique groups were showing.



All times are GMT +1. The time now is 12:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com