473,394 Members | 1,841 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,394 software developers and data experts.

TreeNode Interface

Hi guys,

Don't you guys think that creating an interface for TreeNode can be of help
to programmers? The thing is that my current project involves a TreeView,
ListBoxes and a PropertyGrid. I can pass objects to both the PropertyGrid and
ListBox but I can't do that to the TreeView so we thought with my coworkers,
wouldn't it be cool to just implement an interface that will pass essential
information to the TreeView and be able to reuse the same object anywhere
else in my project? It will make the TreeView very versatile and it helps on
the encapsulation of the data.

If you want more details, just contact me.

Thanks,

humble.apprentice
Nov 17 '05 #1
2 2667
humble.apprentice,

How would you make the TreeView acknowledge the nodes though?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"humble.apprentice" <hu**************@discussions.microsoft.com> wrote in
message news:18**********************************@microsof t.com...
Hi guys,

Don't you guys think that creating an interface for TreeNode can be of
help
to programmers? The thing is that my current project involves a TreeView,
ListBoxes and a PropertyGrid. I can pass objects to both the PropertyGrid
and
ListBox but I can't do that to the TreeView so we thought with my
coworkers,
wouldn't it be cool to just implement an interface that will pass
essential
information to the TreeView and be able to reuse the same object anywhere
else in my project? It will make the TreeView very versatile and it helps
on
the encapsulation of the data.

If you want more details, just contact me.

Thanks,

humble.apprentice

Nov 17 '05 #2
Well, the TreeView has to check the object passed through a new overload for
the Nodes.Add() method. It will check for the methods that are inside the
object which should be the same as the ones in the interface and some others.
To get the name of the node, it should look for the ToString() method and get
the name from it. The interface should look something like this:

public interface ITreeNode
{
// Properties
String Name
{
get
{}
set
{}
}

object Tag
{
get
{}
set
{}
}

object[] Children
{
get
{}
set
{}
}
// Other methods and properties that might be required for the TreeView to
work. . .
}

So the class should look like:

class MyTreeNode : ITreeNode
{
// ITreeNode implementation and other methods
}

And the collection for this class can be something like:

class MyTreeNodeCollection : System.Collections.Generic.List<MyTreeNode>
{
...
}

If you want more ideas or information, let me know.

Yours,

humble.apprentice
"Nicholas Paldino [.NET/C# MVP]" wrote:
humble.apprentice,

How would you make the TreeView acknowledge the nodes though?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"humble.apprentice" <hu**************@discussions.microsoft.com> wrote in
message news:18**********************************@microsof t.com...
Hi guys,

Don't you guys think that creating an interface for TreeNode can be of
help
to programmers? The thing is that my current project involves a TreeView,
ListBoxes and a PropertyGrid. I can pass objects to both the PropertyGrid
and
ListBox but I can't do that to the TreeView so we thought with my
coworkers,
wouldn't it be cool to just implement an interface that will pass
essential
information to the TreeView and be able to reuse the same object anywhere
else in my project? It will make the TreeView very versatile and it helps
on
the encapsulation of the data.

If you want more details, just contact me.

Thanks,

humble.apprentice


Nov 17 '05 #3

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

Similar topics

2
by: Benny Raymond | last post by:
More problems with this... When I run this code, the main form returns an invalid cast exception as it's executing the line "TreeNode n = (TreeNode) this.Nodes;" Does anyone know what would...
0
by: naija naija | last post by:
Hi All, I'm using the TreView Web Control for my MENU. And the Menu is populated from an XML file below. I want a way in which i can manipulate the XML when i want to manage it without having to...
3
by: markaelkins | last post by:
Hi. I am trying to enter a variable in the treenodesrc of a treenode. I am basically trying to send an ID variable into sql to return different records. I've searched everywhere and cannot find the...
0
by: fred | last post by:
I am using the clipboard to copy and paste a TreeNode but the Tag property does not seem to be copied. I use the Tag property for an Object that contains data relating to the TreeNode. The Tag...
3
by: tanya foster | last post by:
Hello, I am re-writing a visual basic .net application(visual studio 2003) in an asp.net application(visual studio 2005). The vb.net application relied on a treeview and hence, treenodes. The...
0
by: John Faris | last post by:
Hi all. I have a class that inherits from TreeNode and adds a generic property, NodeObject. Then I have several other classes that inherit from this class and specify the type of NodeObject as...
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. ...
1
by: jmDesktop | last post by:
I am trying to add nodes with keys to my treeview. I can add general nodes without problem with: //create new node TreeNode newNode = new TreeNode(myIdNumber); //create children TreeNode...
1
by: AAaron123 | last post by:
If you see this posted twice - sorry. My news reader showed my first post as "No Longer Available" I have the following in a .css file. The treeNodes behave as if they were "a" elements. ...
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.