Solved

"Nodes" property in the TreeView control

Posted on 2004-03-22
2
423 Views
Last Modified: 2008-03-17
hello,
I wanted to derive a class from "TreeNodeCollection". (e.g. TreeView.Nodes Property).

Can anybody give a quick explaination as to why they would want to prevent the programmer deriving from this class?

Thanks,
D.
0
Comment
Question by:dave_p_r_b
2 Comments
 
LVL 15

Accepted Solution

by:
SRigney earned 50 total points
ID: 10649335
The treenode collection is a specific child of a treeview.  It has no purpose outside of it's use in a treeview.  I would prevent it from being derived, because the programmer that derived it could then override some of the graphical functionality and not show the graphics within the node the way they need to be shown, which could then break the treeview.

If you are looking to override to only gain access to a few more properties, then I suggest creating a class that contains the text that you want to be displayed, and the additional properties that you want.   When a node is selected then you can cast it to the type of class that you added to the node in the first place and access the additional properties.
0
 

Author Comment

by:dave_p_r_b
ID: 10649615
Thank you.


TreeView myTV;
myTV.Nodes.Add(myTreeNode);

I wished to add extra functionality to the TreeNodeCollection.Add() function to do some extra checks. If, according to my additional checks, it was not ok to add the node then .Add() would return without adding to the collection.

I need to compare the node that is being added to the existing nodes.

I guess I'm going about this the wrong way.


0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
designing in object programming 12 94
Question! 4 39
Code works but breaks when I add one section 4 20
Where does legacy ASP.NET initialize language? 2 26
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

828 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