Solved

"Nodes" property in the TreeView control

Posted on 2004-03-22
2
421 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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