Solved

Create a TreeView using C#

Posted on 2008-06-20
2
1,019 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 200 total points
ID: 21836044
0
 
LVL 13

Accepted Solution

by:
sm394 earned 300 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now