TreeView Demo : TreeView « GUI Windows Form « C# / C Sharp

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. XML
25. XML LINQ
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C# / C Sharp » GUI Windows Form » TreeViewScreenshots 
TreeView Demo
TreeView Demo

/*
Professional Windows GUI Programming Using C#
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury, 
   Zach Greenvoss, Shripad Kulkarni, Neil Whitlow

Publisher: Peer Information
ISBN: 1861007663
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TreeView
{
  /// <summary>
  /// Summary description for TreeViewDemo.
  /// </summary>
  public class TreeViewDemo : System.Windows.Forms.Form
  {
    private System.Windows.Forms.TreeView treeView1;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;
    ImageList il = new ImageList();
    public TreeViewDemo()
    {
      //
      // Required for Windows Form Designer support
      //
      InitializeComponent();

      //
      // TODO: Add any constructor code after InitializeComponent call
      //
    }

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Disposebool disposing )
    {
      ifdisposing )
      {
        if (components != null
        {
          components.Dispose();
        }
      }
      base.Disposedisposing );
    }

    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
         this.treeView1 = new System.Windows.Forms.TreeView();
         this.SuspendLayout();
         // 
         // treeView1
         // 
         this.treeView1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom
            | System.Windows.Forms.AnchorStyles.Left
            | System.Windows.Forms.AnchorStyles.Right);
         this.treeView1.Font = new System.Drawing.Font("Courier New"12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
         this.treeView1.HotTracking = true;
         this.treeView1.ImageIndex = -1;
         this.treeView1.Indent = 30;
         this.treeView1.ItemHeight = 30;
         this.treeView1.LabelEdit = true;
         this.treeView1.Location = new System.Drawing.Point(816);
         this.treeView1.Name = "treeView1";
         this.treeView1.SelectedImageIndex = -1;
         this.treeView1.Size = new System.Drawing.Size(360272);
         this.treeView1.TabIndex = 0;
         // 
         // TreeViewDemo
         // 
         this.AutoScaleBaseSize = new System.Drawing.Size(513);
         this.ClientSize = new System.Drawing.Size(376309);
         this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                      this.treeView1});
         this.Name = "TreeViewDemo";
         this.Text = "TreeView Control";
         this.Load += new System.EventHandler(this.TreeViewDemo_Load);
         this.ResumeLayout(false);

      }
    #endregion

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main() 
    {
      Application.Run(new TreeViewDemo());
    }

    private void TreeViewDemo_Load(object sender, System.EventArgs e)
    {
      // Select icons into the image list
      il.Images.Add(new Icon("KEY04.ICO"));
      il.Images.Add(new Icon("ARW06LT.ICO"));
      il.Images.Add(new Icon("LITENING.ICO"));
      il.Images.Add(new Icon("ARW06UP.ICO"));
      treeView1.ImageList = il ; 
  
      // Create the RootNode
      TreeNode rootNode = treeView1.Nodes.Add("USA");
      rootNode.ImageIndex =;

      // Create the Child nodes for the root
      TreeNode states1 = rootNode.Nodes.Add("New York");
      states1.ImageIndex =;
      TreeNode states2 = rootNode.Nodes.Add("Michigan");
      states2.ImageIndex =;
      TreeNode states3 = rootNode.Nodes.Add("Wisconsin");
      states3.ImageIndex =;
      TreeNode states4 = rootNode.Nodes.Add("California");
      states4.ImageIndex =;

      // Create siblings nodes for the Child nodes 
      TreeNode child = states1.Nodes.Add("Rochester");
      child.ImageIndex = ;
      child =states1.Nodes.Add("new York");
      child.ImageIndex = ;
      child =states1.Nodes.Add("Albany");
      child.ImageIndex = ;

      child = states2.Nodes.Add("Detroit");
      child.ImageIndex = ;
      child =states2.Nodes.Add("Ann Arbor");
      child.ImageIndex = ;
      child =states2.Nodes.Add("Lansing");
      child.ImageIndex = ;

      child = states3.Nodes.Add("Milwaukee");
      child.ImageIndex = ;
      child =states3.Nodes.Add("Madison");
      child.ImageIndex = ;
      child =states3.Nodes.Add("La Cross");
      child.ImageIndex = ;
    
      child = states4.Nodes.Add("Los Angeles");
      child.ImageIndex = ;
      child =states4.Nodes.Add("San Fransisco");
      child.ImageIndex = ;
      child =states4.Nodes.Add("San Diego");
      child.ImageIndex = ;
    }
  }
}


           
       
TreeView.zip( 32 k)
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. Directory Tree HostDirectory Tree Host
10. Subclass TreeView
11. Add Nodes to TreeView
12. TreeView ImageIndex
w___ww._ja_v_a___2s__._c___om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.