473,386 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

TreeView and TreeNode problem

I wrote a class inherit from TreeNode of the system as follow, but when I
try to use it with TreeView object, then it doesn't work, can anyone help?

//============== code to use the inherited node
ServiceServer.InheritTreeNode rootNode = null;
rootNode = treeServices.Nodes.Add(System.Net.Dns.GetHostName( ));
//*** Error: Cannot implicitly convert type 'System.Windows.Forms.TreeNode'
to 'ServiceServer.InheritTreeNode'

//============== inherit class
public class InheritTreeNode:TreeNode
{
public enum NodeType
{
root,
subroot,
content
}
private NodeType nodetype;
......
......
Nov 15 '05 #1
2 5020

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 create
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" <pe*******@hotmail.com> wrote in message
news:#n**************@TK2MSFTNGP10.phx.gbl...
I wrote a class inherit from TreeNode of the system as follow, but when I
try to use it with TreeView object, then it doesn't work, can anyone help?

//============== code to use the inherited node
ServiceServer.InheritTreeNode rootNode = null;
rootNode = treeServices.Nodes.Add(System.Net.Dns.GetHostName( ));
//*** Error: Cannot implicitly convert type 'System.Windows.Forms.TreeNode' to 'ServiceServer.InheritTreeNode'

//============== inherit class
public class InheritTreeNode:TreeNode
{
public enum NodeType
{
root,
subroot,
content
}
private NodeType nodetype;
.....
.....

Nov 15 '05 #2
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]" <ri********@hotmail.com> schreef in bericht
news:uQ**************@TK2MSFTNGP10.phx.gbl...

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 create 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" <pe*******@hotmail.com> wrote in message
news:#n**************@TK2MSFTNGP10.phx.gbl...
I wrote a class inherit from TreeNode of the system as follow, but when I try to use it with TreeView object, then it doesn't work, can anyone help?
//============== code to use the inherited node
ServiceServer.InheritTreeNode rootNode = null;
rootNode = treeServices.Nodes.Add(System.Net.Dns.GetHostName( ));
//*** Error: Cannot implicitly convert type

'System.Windows.Forms.TreeNode'
to 'ServiceServer.InheritTreeNode'

//============== inherit class
public class InheritTreeNode:TreeNode
{
public enum NodeType
{
root,
subroot,
content
}
private NodeType nodetype;
.....
.....


Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: feel | last post by:
Goin' crazy with this recursive function ported from delphi... I send a string like DirA/ DirB /DirC but i get in the treeView each one in a new node.Cant get the child node....!! -DirA -DirB...
4
by: Ian Powell | last post by:
Hi I've got objects in an sorted ArrayList like: P:\ P:\\DOCS P:\\i386 P:\\i386\ASMS P:\\i386\ASMS\1000 P:\\i386\ASMS\1000\MSFT
14
by: Evan Kontos | last post by:
I am trying to implement a Treeview w/an XML file and I even copied and pasted examples from MSDN but can't get them to work. Any suggestions welcome. XML File <TREENODES> <TREENODE...
1
by: tanya foster | last post by:
Hello, I have populated a treeview in asp.net 2.0 from an xmldocument. The treeview structure in the asp web page looks something like... -orderdata -order -lines -operations -materials...
0
by: apenly | last post by:
Hi all- I'm trying to Render a TreeView in a custom control, but I'm receiving a NullReferenceException at runtime. If I put the TreeView on the page it works fine, but as soon as I try to...
0
by: thirunavukarasukm | last post by:
Hai.. i have Problem with Treeview control...... i am developed one web application... i am have many aspx page in this project..but all page undercontrol with treeview .. i am alreay...
0
by: thirunavukarasukm | last post by:
Hai... Problem in Print Friendly Version with treeview control... i am creating one web applications.. in this web application in main page The left side one panel and right side one Iframe...
0
by: divya1949 | last post by:
Create a windows c# application which will Read a xml file and populate nodes in the treeview. 1 On selection of treenode display the child nodes of that node in listview control 2. ...
5
by: Max2006 | last post by:
Hi, I have a TreeView and this is my node style: <asp:TreeNodeStyle ForeColor = "#000000" Font-Size="9px" Font-Bold="false" Width="100px" NodeSpacing="3px" /> The problem is the expand...
3
by: dutsnekcirf | last post by:
I have a treeview control on a custom task pane in Excel. I've enable the ability to use Drag & Drop (by following this how-to) on the treeview to change the order of the nodes. The problem though...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.