Solved

Program with tree and text area

Posted on 2003-11-04
15
215 Views
Last Modified: 2010-05-01
Just getting started. Want a program with tree, capability of adding items, on left and text area on
right to associate with tree item selected.

right now looking for tips on getting started to create tree and associated text areas to be saved.


any past questions or online articles would be helpful

aijohn
0
Comment
Question by:aijohn
  • 7
  • 5
  • 2
  • +1
15 Comments
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9681334
Are you looking to add a node?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9681551
Just curious...
0
 
LVL 4

Expert Comment

by:JohnChapin
ID: 9681627
IN VB6 you got a control called a treeview that can grow and shrink the branches like explorer's folders, using the + sign.
When a node/branch is selected you get a lot of control over what happens, including the ablility to load a text box.
Start a test project and play with it.

Need More? Let me know.
John
0
 

Author Comment

by:aijohn
ID: 9681755
Yep, wanted to add, delete, edit nodes. It's been a while since I used VB
so will just have to get started.

aijohn
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9681980
   TVW.Nodes.Add , tvwFirst, , "1st node"
    TVW.Nodes.Add 1, tvwChild, , "1st Child"
    TVW.Nodes.Add , tvwFirst, , "2nd Node"
    TVW.Nodes.Add 3, tvwChild, , "1st Child"
    TVW.Nodes.Add 3, tvwChild, , "2nd Child"
    TVW.Nodes.Add 3, tvwChild, , "3rd Child"

that will add nodes, for the child the first thing you do is specify the index of the parent, you can see the parents dont define that, but the childs do, 1 and 3 being the indexes.

TVW.Nodes.Remove 6

that will remove the 3rd child node in the example above

TVW.Nodes(1).Text = "Hey there, im the first node, a parent to only 1 child"

that will change the text of the first index node

TVW.Nodes(1).Bold = True

that will set the first index text to be bold
0
 

Author Comment

by:aijohn
ID: 9696500
Will make this a specific question.
I have the tree and the text area.

Would like to click on a tree node and bring up a specific text file in the text area.
0
 
LVL 4

Expert Comment

by:JohnChapin
ID: 9696547
AiJOhn,
the tree-view has a click event when the user selects a node.
In the event you can load the textbox with data from anywhere: code, file, database queries.
You are also allowed to change the node text on the fly, in case you want to show that the node has already been used.
HTH
John
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:aijohn
ID: 9696652
Some code please or point me in the right direction

I have Text1 and Treeview1 with some nodes loaded

I want to click on a specific node and show c:\stuff\story.txt in the text area
0
 
LVL 4

Expert Comment

by:JohnChapin
ID: 9696849
Here is some code to GUIDE you in the direction you need:

Private Sub Form_Load()
Dim nd As Node
Set nd = TreeView1.Nodes.Add(, , "Root", "Root")
Set nd = TreeView1.Nodes.Add("Root", tvwChild, , "c:\_NavCClt.Log")
End Sub

Private Sub TreeView1_Click()
Dim myString As String
'MsgBox "click" & TreeView1.SelectedItem.Text
If TreeView1.SelectedItem.Text = "Root" Then
   TreeView1.SelectedItem.Expanded = True
End If
If TreeView1.SelectedItem.Text = "c:\_NavCClt.Log" Then
    Open TreeView1.SelectedItem.Text For Input As #1
    Line Input #1, myString
    txtAmount2.Text = myString
    Line Input #1, myString
    txtAmount2.Text = txtAmount2.Text & myString
    Close #1

End If
End Sub


Need More? let me know.
John
0
 

Author Comment

by:aijohn
ID: 9697058
Above code creates the node and file is found.
Now how do i get the text file inti the text box, Text1?

aijohn
0
 
LVL 4

Accepted Solution

by:
JohnChapin earned 125 total points
ID: 9697078
this part fills a txt box:
   Open TreeView1.SelectedItem.Text For Input As #1
   Line Input #1, myString
   Text1.Text = myString
   Line Input #1, myString
   Text1.Text = Text1.Text & myString
   Close #1

Hope This Helps
John
0
 

Author Comment

by:aijohn
ID: 9697281
Modified your code using an example from this site as follows
Both your code and this prints on one line . How do I get the line breaks then I think I
am ready to play with this some more , thanks.

Private Sub TreeView1_Click()

Dim myString As String
'MsgBox "click" & TreeView1.SelectedItem.Text
If TreeView1.SelectedItem.Text = "Root" Then
   TreeView1.SelectedItem.Expanded = True
End If
If TreeView1.SelectedItem.Text = "c:\test_dir\note2.txt" Then
 
Open TreeView1.SelectedItem.Text For Input As #1

Dim strData As String

Do Until EOF(1)
    Line Input #1, strData
Text1.Text = Text1.Text & strData
    'strData now contains the line of data - process as needed
Loop
   
   
   Close #1


End If
End Sub
0
 

Author Comment

by:aijohn
ID: 9698059
I did it.

Multiple lines set to true


and

& vbCrLf
0
 
LVL 4

Expert Comment

by:JohnChapin
ID: 9701027
Are you finished with this, or are there more questions to be resolved?
John
0
 

Author Comment

by:aijohn
ID: 9701603
Your comments have been a great help.  i will give the points and then come back later with more questions.

aijohn
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ms access #TYPE! error on report when no data 4 68
vb6 programatically bring window to front 8 65
VBA color chart bars 12 78
Hide vba in gp 7 83
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now