To accomplish that, you also should create your own TreeView, by inheriting
from the default TreeView, so you'd have control over the Add method etc.
--
Greetz,
Jan
__________________________________
Read my weblog:
http://weblogs.asp.net/jan
"Rick Strahl [MVP]" <rickstrahl@hotmail.com> schreef in bericht
news:uQGzfy6uDHA.1764@TK2MSFTNGP10.phx.gbl...[color=blue]
>
> You need to cast the tree node:
>
> rootNode = (InheritTreeNode)
> treeServices.Nodes.Add(System.Net.Dns.GetHostName( ));
>
> But that still won't do what you think it should because the node added is
> actually created by the Add method. In other words just casting it isn't
> going to give you magically an inherited node since the method didn't[/color]
create[color=blue]
> that.
>
> +++ Rick ---
>
> Rick Strahl
> West Wind Technologies
>
http://www.west-wind.com/
>
http://www.west-wind.com/wwHelp
> ----------------------------------
> Making waves on the Web
>
>
> "pei_world" <pei_world@hotmail.com> wrote in message
> news:#nSGj$5uDHA.2520@TK2MSFTNGP10.phx.gbl...[color=green]
> > I wrote a class inherit from TreeNode of the system as follow, but when[/color][/color]
I[color=blue][color=green]
> > try to use it with TreeView object, then it doesn't work, can anyone[/color][/color]
help?[color=blue][color=green]
> >
> > //============== code to use the inherited node
> > ServiceServer.InheritTreeNode rootNode = null;
> > rootNode = treeServices.Nodes.Add(System.Net.Dns.GetHostName( ));
> > //*** Error: Cannot implicitly convert type[/color]
> 'System.Windows.Forms.TreeNode'[color=green]
> > to 'ServiceServer.InheritTreeNode'
> >
> >
> >
> > //============== inherit class
> > public class InheritTreeNode:TreeNode
> > {
> > public enum NodeType
> > {
> > root,
> > subroot,
> > content
> > }
> > private NodeType nodetype;
> > .....
> > .....
> >
> >[/color]
>
>[/color]