Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 13th, 2006, 07:33 AM
Registered User
Join Date: Nov 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default insert object into tree node

i want to make tree but how to insert object into tree so every node can store object not only text.

Old November 13th, 2006, 12:06 PM
Friend of Wrox
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts

This is no problem with C#, if you are asking about the TreeView control.
Each node has a tag, and the tag points to an object. When you add an item to the treeview, merely set its tag to the object you want to associate. When you need to use the object, cast the Tag of the node to the object type you put in there.

Of course, the tag can also contain basic types, such as ints or strings - and if you use it in this manner you also need to cast it to whatever type you are putting into it.

Woody Z http://www.learntoprogramnow.com

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
How to insert a New node into the XML Document VB jabrouni1 Classic ASP XML 1 January 26th, 2007 06:11 AM
using hyperlink controls as node with tree control connect2sandep ASP.NET 1.0 and 1.1 Professional 0 October 27th, 2005 02:00 PM

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