Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

"Nodes" property in the TreeView control

Posted on 2004-03-22
2
Medium Priority
?
427 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

721 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