472,805 Members | 1,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Learnig to Build a Tree View Control

Does anyone know of a good article that discusses creating a "Tree
View" control in ASP.NET? Or perhaps a Tree View Control that comes
with source code? I have come across a lot of tree controls for ASP.NET
however most of them are already compiled and don't come with source
code. I am really just looking for an example on how to create my own
Tree Control. Thanks a bunch.

Nov 19 '05 #1
10 2451
Creating a Tree View Control is the same as creating or designing an
application. You enumerate a set of requirements, look at the available
tools and technologies, figure out what will satisfy your requirements, and
come up with a plan. Rather than looking at examples of how other people
soved the problem, why not look at this as an opportunity to practice your
analysis and design skills?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"dwok" <de***@wubbafish.net> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Does anyone know of a good article that discusses creating a "Tree
View" control in ASP.NET? Or perhaps a Tree View Control that comes
with source code? I have come across a lot of tree controls for ASP.NET
however most of them are already compiled and don't come with source
code. I am really just looking for an example on how to create my own
Tree Control. Thanks a bunch.

Nov 19 '05 #2
It is extremely simple.
While I do not have the time to go into greater detail regarding how it
is the topics you should be familiar with already are
Using the Viewstate to store your own variables.
Creating custom classes that are serializable and deserialiazable
and Recursiveness

if i were you i would build a custom class that implements ICollection.
This will be referred to as your NodeCollection from here on out.
You will have another custom class. This will be referred to as your
Node from here on out.
Both have to be marked as Serializable. Look up this Attribute in the
msdn library.
For speed skae you should implement ISerializable and implement the
special constructor and add and retrieve all of your variables
manually. This requires more code but offers a significate performance
boost as it doesnot have to use reflection when serializaing and
deserializing.

Your TreeNode will have a property that is of the type NodeCollection.
you will override LoadViewState and SaveViewState and by simply adding
your Tree's Node Collection to the viewstate everything is serialized
automatically and deserialized. All you have to do is add and retrieve
it from the Viewstate.

Rendering is simply a matter of Recursive ness.
foreach (treenode in treenodecollection)
{
render node
callself(treenode.Nodes)
}

Hope this is helpful in any way

Nov 19 '05 #3
spoken like a true MVP

Nov 19 '05 #4
Did you intend for this to be helpful?

Nov 19 '05 #5
if you goto the book store and look at the javascript/html section, you
should find lots of material on this and other html ui components. in the
asp.net seciton you may even find .net implimentations.

if you go to any website that has a tree control you like, with the browser
view source to see the code. firefox has really good tools for this.

-- bruce (sqlwork.com)

"dwok" <de***@wubbafish.net> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
| Did you intend for this to be helpful?
|
Nov 19 '05 #6
Hello Dwok,
Check out the control gallery at ww.asp.net:
It has an entire section dedicated to treeviews:
http://www.asp.net/ControlGallery/de...=28&tabindex=2

I personally have used this one with success (it's free):
http://www.asp.net/ControlGallery/Co...014&tabindex=2

Some tips to get you started:
1 - Think out your requirements. Do the nodes need to be multi-line? Should
they be able to contain any HTML (images, tables, etc...) or just single
literal strings or links.
2 - How will you set the data? With an xml file, from a DataTable (with
recursive columns), programatically?
3 - Figure out your javascript/html needs: (1) how to children collapsed
(hidden), (2) how to persist across postback. Look at the view-source for
other successful treeviews.
"dwok" wrote:
Does anyone know of a good article that discusses creating a "Tree
View" control in ASP.NET? Or perhaps a Tree View Control that comes
with source code? I have come across a lot of tree controls for ASP.NET
however most of them are already compiled and don't come with source
code. I am really just looking for an example on how to create my own
Tree Control. Thanks a bunch.

Nov 19 '05 #7
Hi,

For building the treeview control u should decide on which data source u
r going to use to populate the tree view. i have developed a treeview control
in which the nodes and all the info. required for the elements in the tree
view control are in XML files. then using XML dom we can parse through that
and develop the tree view control.
for more info. regarding the tree view control u can look into the
june2004 edition of MSDN Magazine.

Regards,
Sundararajan.S

"Tim Stall" wrote:
Hello Dwok,
Check out the control gallery at ww.asp.net:
It has an entire section dedicated to treeviews:
http://www.asp.net/ControlGallery/de...=28&tabindex=2

I personally have used this one with success (it's free):
http://www.asp.net/ControlGallery/Co...014&tabindex=2

Some tips to get you started:
1 - Think out your requirements. Do the nodes need to be multi-line? Should
they be able to contain any HTML (images, tables, etc...) or just single
literal strings or links.
2 - How will you set the data? With an xml file, from a DataTable (with
recursive columns), programatically?
3 - Figure out your javascript/html needs: (1) how to children collapsed
(hidden), (2) how to persist across postback. Look at the view-source for
other successful treeviews.
"dwok" wrote:
Does anyone know of a good article that discusses creating a "Tree
View" control in ASP.NET? Or perhaps a Tree View Control that comes
with source code? I have come across a lot of tree controls for ASP.NET
however most of them are already compiled and don't come with source
code. I am really just looking for an example on how to create my own
Tree Control. Thanks a bunch.

Nov 19 '05 #8
How do you think I came to become one? ;-)

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"re****@community.nospam" <ma**********@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
spoken like a true MVP

Nov 19 '05 #9
If you're replying to me, the answer would be "yes, doubtless more helpful
than you realize."

Which is more helpful - to feed a man a fish, or to teach a man to fish?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"dwok" <de***@wubbafish.net> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Did you intend for this to be helpful?

Nov 19 '05 #10
Thank you for all the replies. A lot of people suggested on how to
start planning for a TreeView control but what I am really looking for
is an example. As I see it there are many things to consider when
developing an ASP.NET TreeView control.

1. client-side vs. server-side interaction
2. datasource (XML, Dataset, Collection, etc..)
3. Node properties
4. Load entire tree vs. single node

These are all things that I think would be made much clearer to me if
I had an example to look at. There are many great treeview controls out
there for ASP.NET however I would like to be able to look at the source
code in order to understand how they are created.

Nov 19 '05 #11

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

Similar topics

0
by: Tree menu using XML | last post by:
I have one XML file that has nodes and sub node and each and every node has the attribute call visible if its value is true then diplay this node else don't display thid node, but this condition i...
1
by: Nick Warrington | last post by:
Hi all, I am having a small problem with a tree control I am playing with. I have created a custom tree view that displays nodes with a linktext control to the right of the nodes. When the...
1
by: Kaye | last post by:
It seems that when I dynamically resize items in a tree-view control, using TVM_SETITEM and the TVITEMEX iIntegral member, things go awry. The window draws properly, but it seems like the RECTs for...
3
by: Alan Silver | last post by:
Hello, I am just looking at the tree view control, which looks very good, but has some apparent limitations. This could easily be my lack of experience with it. Specifically, I have two...
1
by: JN | last post by:
Hi All, I have a tree view which has parent nodes of each letter of the alphabet. The root node will be the customers name that relate to the parent node letter. I also have a gridview which is...
0
by: Santosh | last post by:
Asp.Net tree view control font problem Dear all i am downloading MS tree view control . i want to change the font size and font name of the tree view control i am wrtitting code for it like ...
0
by: rinishrk | last post by:
Hi, I have a web application that contains subfolders Admin and User with related webpages inside them. Within the Admin folder I have a page containing a Tree View Control.I want this tree view...
1
by: perspolis | last post by:
Hi all I'm looking for a Combobox that displays tree. Does anyone has a source code for that??? thanks in advance
1
by: BeginingOfLife | last post by:
i am using a java script to create a tree view in my html page. i got that script from this link : http://destroydrop.com/javascripts/tree/ given script is static script creations for tree...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.