By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,671 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,671 IT Pros & Developers. It's quick & easy.

Creating a new TreeNodeCollection (and getting handles,...)

P: n/a
I have derived new classes for the TreeNode and TreeView classes that
Microsoft provides. Since the TreeNodeCollection class is sealed I
created my own class that implements the IList interface.

However, the original TreeNodeCollection class does something
important on the "Add" method where it assigns the "TreeView" and
"Handle" to the TreeNode object that you are adding. I need this
information - and can not figure out how they are doing this.
Needless to say - my class that I created does not do this.

Does anyone have some code for Microsoft's implementation of the
TreeNodeCollection class - or does anyone have any idea of where I
should start?

It is very annoying that they sealed this class (with internal
constructor)...
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
This is the way I got around the problem. I'm not thrilled that it's
the best solution, but it does work...

public class ICNodeCollection
{
private TreeNodeCollection nodes;

public ICNodeCollection(TreeNodeCollection treeNodes)
{
nodes = treeNodes;
}
.... (add special functions for NodeCollection class)
}

public class ICTreeNode : System.Windows.Forms.TreeNode
{
private ICNodeCollection nodes;

public ICTreeNode() : base()
{
nodes = new ICNodeCollection(base.Nodes);
}

....
}

public class ICTreeView : System.Windows.Forms.TreeView
{
private ICNodeCollection nodes;

public ICTreeView() : base()
{
nodes = new ICNodeCollection(base.Nodes);
InitializeTreeView();
}
...
}

It's just annoying that Microsoft did not allow us to derive from the
TreeNodeCollection class.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 15 '05 #2

P: n/a
This is the way I got around the problem. I'm not thrilled that it's
the best solution, but it does work...

public class ICNodeCollection
{
private TreeNodeCollection nodes;

public ICNodeCollection(TreeNodeCollection treeNodes)
{
nodes = treeNodes;
}
.... (add special functions for NodeCollection class)
}

public class ICTreeNode : System.Windows.Forms.TreeNode
{
private ICNodeCollection nodes;

public ICTreeNode() : base()
{
nodes = new ICNodeCollection(base.Nodes);
}

....
}

public class ICTreeView : System.Windows.Forms.TreeView
{
private ICNodeCollection nodes;

public ICTreeView() : base()
{
nodes = new ICNodeCollection(base.Nodes);
InitializeTreeView();
}
...
}

It's just annoying that Microsoft did not allow us to derive from the
TreeNodeCollection class.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 15 '05 #3

P: n/a
This is the way I got around the problem. I'm not thrilled that it's
the best solution, but it does work...

public class ICNodeCollection
{
private TreeNodeCollection nodes;

public ICNodeCollection(TreeNodeCollection treeNodes)
{
nodes = treeNodes;
}
.... (add special functions for NodeCollection class)
}

public class ICTreeNode : System.Windows.Forms.TreeNode
{
private ICNodeCollection nodes;

public ICTreeNode() : base()
{
nodes = new ICNodeCollection(base.Nodes);
}

....
}

public class ICTreeView : System.Windows.Forms.TreeView
{
private ICNodeCollection nodes;

public ICTreeView() : base()
{
nodes = new ICNodeCollection(base.Nodes);
InitializeTreeView();
}
...
}

It's just annoying that Microsoft did not allow us to derive from the
TreeNodeCollection class.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.