Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

"Nodes" property in the TreeView control

Posted on 2004-03-22
2
Medium Priority
?
428 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 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Loops Section Overview
Suggested Courses

963 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