Solved

treeview building

Posted on 1998-12-14
6
202 Views
Last Modified: 2010-05-03
i am trying to build a stair tree. i have succeeded in building a root node and a few children with the treeview.nodes.add but for some reason when i try to build a two level tree of questions answers meaning:
q
---a
q
---a
q
---a
as it is writen in the help file, i get a debug msg. that the object is not found. can you write me an example that builds a tree like the example above.
thank you.
p.s i'm using vb6.
0
Comment
Question by:ilanm
  • 4
  • 2
6 Comments
 
LVL 7

Accepted Solution

by:
Inteqam earned 50 total points
ID: 1450069
insert a treeview in a form and paste the following:

Private Sub Form_Load()
Dim n As Node

Set n = Me.TreeView1.Nodes.Add(, , "root", "root")
Set n = Me.TreeView1.Nodes.Add("root", tvwChild, "q1", "q")
Set n = Me.TreeView1.Nodes.Add("root", tvwChild, "q2", "q")
Set n = Me.TreeView1.Nodes.Add("root", tvwChild, "q3", "q")
Set n = Me.TreeView1.Nodes.Add("q1", tvwChild, "a1", "a")
Set n = Me.TreeView1.Nodes.Add("q2", tvwChild, "a2", "a")
Set n = Me.TreeView1.Nodes.Add("q3", tvwChild, "a3", "a")

End Sub


0
 

Author Comment

by:ilanm
ID: 1450070
thank you for your answer, but i meant a dynamic tree where there could be 100 question answers or 3.
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 1450071
try this
insert a treeview in a form and paste the following:

Private Sub Form_Load()
Dim n As Node
Dim Count as integer
Dim strKeyq as String
Dim strKeta
Set n = Me.TreeView1.Nodes.Add(, , "root", "root")
' use a counter for the Q's
while there is more questions
   count=count+1
   strKeyq="q"+cstr(Count)
   strKeya="a"+Cstr(Count)
 Set n = Me.TreeView1.Nodes.Add("root", tvwChild, strkeyq, "q")
 Set n = Me.TreeView1.Nodes.Add(strkeyq, tvwChild, strkeya, "a")
wend
End Sub

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ilanm
ID: 1450072
Inteqam i still get the error msg of object not found.

0
 
LVL 7

Expert Comment

by:Inteqam
ID: 1450073
it works will in my PC ,
where the error happens?

0
 
LVL 7

Expert Comment

by:Inteqam
ID: 1450074
mis spilled Dim strKeta  
it must be Dim strKeya

try now.

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Saving history changes to sub form 4 52
Copy a row 12 70
how to know if my Checkbox is True in VB6.0? 9 66
RUNRMTCMD from AS/400 13 101
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question