TreeView ImageIndex : 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 ImageIndex
 
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class Form1 : System.Windows.Forms.Form {
    private System.Windows.Forms.TreeView treeView1;
    ImageList il = new ImageList();
    public Form1() {
        this.treeView1 = new System.Windows.Forms.TreeView();
        this.SuspendLayout();
        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.SelectedImageIndex = -1;
        this.treeView1.Size = new System.Drawing.Size(360272);

        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.Text = "TreeView Control";
        this.Load += new System.EventHandler(this.Form1_Load);
        this.ResumeLayout(false);

    }
    [STAThread]
    static void Main() {
        Application.Run(new Form1());
    }

    private void Form1_Load(object sender, System.EventArgs e) {
        il.Images.Add(new Icon("1.ICO"));
        il.Images.Add(new Icon("2.ICO"));
        il.Images.Add(new Icon("3.ICO"));
        il.Images.Add(new Icon("4.ICO"));
        treeView1.ImageList = il;

        TreeNode rootNode = treeView1.Nodes.Add("USA");
        rootNode.ImageIndex = 0;

        TreeNode states1 = rootNode.Nodes.Add("a");
        states1.ImageIndex = 1;
        TreeNode states2 = rootNode.Nodes.Add("b");
        states2.ImageIndex = 1;
        TreeNode states3 = rootNode.Nodes.Add("c");
        states3.ImageIndex = 1;
        TreeNode states4 = rootNode.Nodes.Add("d");
        states4.ImageIndex = 1;

        TreeNode child = states1.Nodes.Add("A");
        child.ImageIndex = 2;
        child = states1.Nodes.Add("e");
        child.ImageIndex = 2;
        child = states1.Nodes.Add("f");
        child.ImageIndex = 2;

        child = states2.Nodes.Add("g");
        child.ImageIndex = 2;
        child = states2.Nodes.Add("h");
        child.ImageIndex = 2;
        child = states2.Nodes.Add("i");
        child.ImageIndex = 2;

        child = states3.Nodes.Add("j");
        child.ImageIndex = 2;
        child = states3.Nodes.Add("k");
        child.ImageIndex = 2;
        child = states3.Nodes.Add("l");
        child.ImageIndex = 2;

        child = states4.Nodes.Add("m");
        child.ImageIndex = 2;
        child = states4.Nodes.Add("n");
        child.ImageIndex = 2;
        child = states4.Nodes.Add("o");
        child.ImageIndex = 2;
    }
}

 
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. Add Nodes to TreeView
w_w___w.j___a___v__a_2s___.__com_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.