Properties of TreeNode

wabs27

Member
Joined
Jul 31, 2006
Messages
11
Programming Experience
5-10
Hi,

I am pretty new to TreeView and ran into a bit of a problem. I am currently populating my treeview from a datareader and it is working fine with the parent and child nodes. My problem is that I need to display the FieldName from the database, but I still need the FieldID value to make changes to the database. So for instance, if a certain node is selected and a button is clicked, I want to be able to know the FieldID - not the FieldName. Currently I can do TreeView1.SelectedNode.Text to get me the FieldName or TreeView1.SelectedNode.FullPath to get me the full path. But this is useless to me since I need to FieldID (primary key field for my database).

I know that with other .net controls there are DisplayMember and ValueMember properties. Is there a way to do this with a treeview.

P.S. - How do you add code snippets into these forums?
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,552
Location
Norway
Programming Experience
10+
You could store the id in the Tag property of each node.

About code tags: http://www.vbdotnetforums.com/misc.php?do=bbcode You can also use advanced posting editor click one of the code buttons to automatically wrap selected text with tags.
 
Top Bottom