Add Nodes to TreeView : TreeView « GUI Windows Form « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » GUI Windows Form » TreeViewScreenshots 
Add Nodes to TreeView
 

using System;
using System.Drawing;
using System.Windows.Forms;
   
class SimpleTreeView: Form
{
     public static void Main()
     {
          Application.Run(new SimpleTreeView());
     }
     public SimpleTreeView()
     {
          Text = "Simple Tree View";
   
          TreeView tree = new TreeView();
          tree.Parent = this;
          tree.Dock = DockStyle.Fill;
   
          tree.Nodes.Add("Animal");
          tree.Nodes[0].Nodes.Add("A");
          tree.Nodes[0].Nodes[0].Nodes.Add("A1");
          tree.Nodes[0].Nodes[0].Nodes.Add("A2");
          tree.Nodes[0].Nodes[0].Nodes.Add("A3");
          tree.Nodes[0].Nodes.Add("B");
          tree.Nodes[0].Nodes[1].Nodes.Add("B1");
          tree.Nodes[0].Nodes[1].Nodes.Add("B2");
          tree.Nodes[0].Nodes.Add("C");
          tree.Nodes[0].Nodes[2].Nodes.Add("C1");
          tree.Nodes[0].Nodes[2].Nodes.Add("C2");
          tree.Nodes[0].Nodes[2].Nodes.Add("C3");
          tree.Nodes.Add("D");
          tree.Nodes[1].Nodes.Add("D1");
          tree.Nodes[1].Nodes.Add("D2");
          tree.Nodes[1].Nodes.Add("D3");
          tree.Nodes.Add("E");
          tree.Nodes[2].Nodes.Add("E1");
          tree.Nodes[2].Nodes.Add("E2");
          tree.Nodes[2].Nodes.Add("E3");
     }
}

 
Related examples in the same category
1.Recursively load Directory info into TreeViewRecursively load Directory info into TreeView
2.Drag and drop Tree NodeDrag and drop Tree Node
3.Get Selected Node Full PathGet Selected Node Full Path
4.Custom TreeView
5.TreeView ExampleTreeView Example
6.TreeView Drag And DropTreeView Drag And Drop
7.TreeView Data BindingTreeView Data Binding
8.Read an XML Document and display the file as a TreeRead an XML Document and display the file as a Tree
9.TreeView DemoTreeView Demo
10.Directory Tree HostDirectory Tree Host
11.Subclass TreeView
12.TreeView ImageIndex
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.