Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2010 > BOOK: Visual Basic 2010 Programmer's Reference
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Visual Basic 2010 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2010 Programmer's Reference by Rod Stephens; ISBN: 9780470499832
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2010 Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 21st, 2011, 04:23 AM
Authorized User
Points: 193, Level: 3
Points: 193, Level: 3 Points: 193, Level: 3 Points: 193, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Nov 2011
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Question Making a node in tree view Clickable

Hello Rod,

Thank you again for your previous help. I have several projects going as I am trying to learn Visual Basic. You have given me immeasurable help in tying up many loose ends in those projects. I do have another question if it is not too much trouble.

I am working on a project to generate a type of document index in which the index will be in tree view, the same as Windows Explorer. My goal is that the end user will be able to create the list in tree view without of course having to write the code. After creating the list he will be able click on the various nodes and open up the desired file in the document index. Below I have included some of the code that I am using so the user can create the list.

Private Sub DocumentIndex_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLevelOne.Click

Dim NewNodes As String
NewNodes = TextBox1.text

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLevelTwo.Click

Dim ChildNode As String
ChildNode = TextBox2.Text

Dim objNode As TreeNode
objNode = TreeView1.SelectedNode()

End Sub

I face two specific challenges in this project:

1) How do I write the code so that the End User can make the various Nodes of the Tree View List clickable? What I envision is that the End User would select a particular node, click on a button to open a Dialog box to view the document files and then select the file that they want to Node to open. The program would automatically generate the necessary code so that someone who was using the document index could click on the node and open the desired file.

2) After the End User creates their list in Tree View how do they save it so that it is not lost when the application is closed?

Can you give me any insight into these challenges. Thanks again.

Reply With Quote
  #2 (permalink)  
Old December 21st, 2011, 12:59 PM
Rod Stephens's Avatar
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts

Hi Gary,

You can't really write code that modifies itself in VB. I've done it using assembly code and it's a nightmare anyway so you don't really want to go there.

What you should do is make a data structure that can hold the information so later you can open a program and read the information to figure out what to do about it. In this case, you can probably store the information for each tree view node in the node's Tag property. Each node is represented by a TreeNode object and that object's Tag property can hold anything you like. For example, the Tag property could hold a document name or another object that includes the document's name and any other information that you need.

When the user clicks on a node, you can get the Tag property and pull up the document.

The remaining issue is how do you store all of this. You could try using an XML file. They're hierarchical so they can store the information in a TreeView in a reasonably intuitive way. Or you could save the information in a plain text file and use indentation to show the TreeView's structure.

Here are some examples that may help:


I hope that helps.

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
traverse the whole tree without knowing the node dipsut XSLT 3 June 17th, 2011 07:49 AM
Not able to see the last tree view node suji C# 0 October 11th, 2008 12:34 AM
Search A Hierarchy Tree for Node where id=value sdaspen XSLT 4 February 2nd, 2007 06:34 PM
insert object into tree node Xeon-Yk C# 1 November 13th, 2006 12:06 PM
Making a tree using jsp and html viren_balaut HTML Code Clinic 1 September 10th, 2004 10:45 AM

All times are GMT -4. The time now is 09:47 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.