473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

TreeNode design is wrong

Why TreeNode is a string? It should hold a Object and get label from
Object.ToString(). Then much better. Easy to trace all objects in a TreeView.
Nov 16 '05 #1
2 1143
How would that work exactly? A TreeView control is often used to simply
display strings, without a backing object.

Even when an object is used, what if it's not your class, so you didn't get
a say in what is returned by ToString? If it is your class, do you really
want to change the ToString method just so it can have a value that can be
used in a specific control? What if ToString conatins more information than
you'd like in your UI? Or less? What if you want to have the TreeNode text
vary depending on something else going on in your app?

If this is something that will help you, you should override TreeNode to
automatically set the Text property to be equal to the string returned by
tag.ToString. As a design for the base TreeNode, however, it would be
extremely limiting.

"Fei Li" wrote:
Why TreeNode is a string? It should hold a Object and get label from
Object.ToString(). Then much better. Easy to trace all objects in a TreeView.

Nov 16 '05 #2
> Why TreeNode is a string?

? TreeNode is an object.
It should hold a Object and get label from
Object.ToString(). Then much better. Easy to trace all objects in a

TreeView.

You can derive your own node from TreeNode. IIRC, you can also store an
object for each node in the Tag property.

--
William Stacey, MVP
http://mvp.support.microsoft.com
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: scoobydoo | last post by:
Hello, I am trying to implement ICloneable's Clone() function, using Serialization. However, my code causes an exception. I have a class derived from TreeNode called "Node1". In Node1, I...
2
by: Fabio Cannizzo | last post by:
I execute the following code: myTreeNode.NodeFont = new Font( ... ); However this does not change the Bounds of the TreeNode and as a result the TreeNode's Text does no longer fit and it in...
1
by: naijacoder naijacoder | last post by:
Hi Guys, I have an application below that is treeview menu populated from the database which works with asp.net webmatrix.But when i put it into code behind in Visual Studio.Net it gives the...
2
by: | last post by:
When I am debugging I can see when treenode.nodes is empty because the count property of nodes will be zero, but at design time the count property is non existant. Is there anyway of checking...
5
by: Don | last post by:
I've created a small test class to extend the Treenode object and am having mixed success. In the Treeview's 'BeforeExpand' event I've used code from the help topic "Adding Custom Information to...
1
by: jmDesktop | last post by:
I am trying to add nodes with keys to my treeview. I can add general nodes without problem with: //create new node TreeNode newNode = new TreeNode(myIdNumber); //create children TreeNode...
1
by: AAaron123 | last post by:
If you see this posted twice - sorry. My news reader showed my first post as "No Longer Available" I have the following in a .css file. The treeNodes behave as if they were "a" elements. ...
0
by: sanjeevsmedhi | last post by:
Hi all, I am a beginner to C# and i need to create a custom Treenode. I will have a treeview with general TreeNode node but there will be no checkbox there. Now in that treeview if i will have...
0
by: Tom | last post by:
I have your classic WinForm treeview that uses an image list with 2 images: 1. An open folder. 2. A closed folder. The events that I have registered for are: 1. afterselect 2. afterexpand...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.