473,809 Members | 2,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.I nheritTreeNode rootNode = null;
rootNode = treeServices.No des.Add(System. Net.Dns.GetHost Name());
//*** 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 5034

You need to cast the tree node:

rootNode = (InheritTreeNod e)
treeServices.No des.Add(System. Net.Dns.GetHost Name());

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*******@hotm ail.com> wrote in message
news:#n******** ******@TK2MSFTN GP10.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.I nheritTreeNode rootNode = null;
rootNode = treeServices.No des.Add(System. Net.Dns.GetHost Name());
//*** 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********@hot mail.com> schreef in bericht
news:uQ******** ******@TK2MSFTN GP10.phx.gbl...

You need to cast the tree node:

rootNode = (InheritTreeNod e)
treeServices.No des.Add(System. Net.Dns.GetHost Name());

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*******@hotm ail.com> wrote in message
news:#n******** ******@TK2MSFTN GP10.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.I nheritTreeNode rootNode = null;
rootNode = treeServices.No des.Add(System. Net.Dns.GetHost Name());
//*** 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
821
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 -DirC instead of: DirA | - DirB
4
7602
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
6837
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 TEXT="Document-1"> <TREENODE TEXT="Folder-1" EXPANDED="true"> <TREENODE TEXT="Document-2" />
1
4755
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 -material
0
2490
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 render it within my control it crashes and burns. I've even tried placing it within another control (a PlaceHolder) and tried to render the PlaceHolder to no avail. Any ideas on how to fix this problem? Here's my code:
0
1208
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 download the IE Web Controls from microsoft site..
0
1125
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 control.. i am go to run the page the treeview control to expand corresponding page target to iframe control..
0
3315
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. Provide following view properties to listview, through View menu a. Tile b. Icon
5
7525
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 button (+) resides right at the middle of multi-line text. Can I make the expand button top align instead of middle align?
3
4707
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 is if I close the application and then go back in, the nodes are back in the order they were before I had reordered them. Is there a way that I can modify my DragDrop event to permanently change the index of the nodes? Here's my code if you're...
0
9600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10633
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.