Solved

vb.net TreeView how to set value property

Posted on 2010-09-06
10
511 Views
Last Modified: 2013-11-27
I am filling a TreeView using the code below, how do I set the value property for each of the two add new node lines? Just having trouble with syntax.
' Add a root TreeNode for each Company object in the ArrayList.

Dim company2 As Company

For Each company2 In companyArray



   tvwPreAlert.Nodes.Add(New TreeNode(company2.CompanyLedgerType + " ~ " + company2.CompanyName))

      

' Add a child TreeNode for each PreAlert object in the current Company object.



Dim prealert1 As PreAlertNumber

   For Each prealert1 In company2.CompanyPreAlerts



   tvwPreAlert.Nodes(companyArray.IndexOf(company2)).Nodes.Add( New TreeNode(prealert1.PreAlertID))



   Next prealert1

Next company2

Open in new window

0
Comment
Question by:TeDeSm
  • 5
  • 3
  • 2
10 Comments
 
LVL 12

Expert Comment

by:GMGenius
Comment Utility
best way is to add a Node variable
like so (not tested
Dim xNode as Node
xNode =  tvwPreAlert.Nodes.Add(New TreeNode(company2.CompanyLedgerType + " ~ " + company2.CompanyName))
xNode.Value = "your value"
0
 
LVL 12

Expert Comment

by:GMGenius
Comment Utility
Sorry

Dim xNode As TreeNode
 
0
 
LVL 12

Expert Comment

by:GMGenius
Comment Utility
Infact you can do away with the (New TreeNode) statement prefix
0
 
LVL 12

Expert Comment

by:GMGenius
Comment Utility
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
Comment Utility
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:TeDeSm
Comment Utility
Thanks for the help.

I have the following, however the Value property is not available, whereas Text is.

I may have to include record ID's as part of the text and parse it out for use, a bit like I had to do in MS Access VBA activeX treeview control.

Dim company2 As Company
Dim tvwNode As TreeNode
For Each company2 In companyArray

tvwNode = tvwPreAlert.Nodes.Add(company2.CompanyLedgerType + " ~ " + company2.CompanyName)
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
Comment Utility
Read about the Tag Property....
0
 
LVL 12

Accepted Solution

by:
GMGenius earned 250 total points
Comment Utility
You may also wish to look at the .name property as well as the .tag property
0
 
LVL 18

Assisted Solution

by:John (Yiannis) Toutountzoglou
John (Yiannis) Toutountzoglou earned 250 total points
Comment Utility
0
 

Author Closing Comment

by:TeDeSm
Comment Utility
Just the job I can give these node properties a value, I should be able to get to them fairly easily later on.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Deserialize JSON array VB.Net problem 3 36
Where to begin studying? 5 63
Wpf develop 5 29
XML & .net 5 14
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

6 Experts available now in Live!

Get 1:1 Help Now