Solved

"Nodes" property in the TreeView control

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now