Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Create a TreeView using C#

Posted on 2008-06-20
2
Medium Priority
?
1,028 Views
Last Modified: 2008-06-21
I need some help with a C# problem. I have a database that has three tables in it:

ServerStatus
Server
Database

What I want to do is create a TreeView that looks like this:

- Server Status
  - Server
    - Database

eg.

- Online
  - ApplicationServer20
    - AdventureWorks
    - Pubs
    - Northwind
+ Offline
+ Shutdown

Does anyone know how I can implement this?
0
Comment
Question by:computerstreber
2 Comments
 
LVL 16

Assisted Solution

by:CuteBug
CuteBug earned 800 total points
ID: 21836044
0
 
LVL 13

Accepted Solution

by:
sm394 earned 1200 total points
ID: 21837648
you can add nodes in tree after getting result set from you query like
//--------------------------------------------------------------
foreach (DataRow row in ds.Tables[0].Rows)
                {
                           TreeNode newNode = new TreeNode(row["Column_NAME"].ToString());
                            treeView1.Nodes.Add(newNode);
                     }//end for
//--------------------------------------------------------------------
then you can add further child nodes through Recursive function  
OR
on node click event i.e.
treeView1.SelectedNode.Nodes.Add(newNode);

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Integration Management Part 2
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question