Treeview Control Populating Problem

M

misseill

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.
 
M

misseill

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top