TreeView Control Demo in C#

Download
Download is available until [expire_date]
  • Version
  • Download 43
  • File Size 43.94 KB
  • File Count 1
  • Create Date April 25, 2016
  • Last Updated April 25, 2016

TreeView Control Demo in C#

TreeView Control Demo in C#

A treenode is a control that allows you to display items in a hierarchical structure. In this c# program, sample nodes are presented and selected node will be displayed in a messagebox.

Images can also be inserted as a node in this control, treenode with images will be uploaded later on.

Source code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
            treeView1.Nodes.Add("Programming");
            treeView1.Nodes[0].Nodes.Add("Visual Basic.net");
            treeView1.Nodes[0].Nodes.Add("Java");
            treeView1.Nodes[0].Nodes.Add("C#");
            treeView1.Nodes.Add("Database");
            treeView1.Nodes[1].Nodes.Add("MS Access");
            treeView1.Nodes[1].Nodes.Add("MySQL");
            treeView1.Nodes[1].Nodes.Add("SQL Server");        
            treeView1.Nodes.Add("Search Engine");
            treeView1.Nodes[2].Nodes.Add("Google");
            treeView1.Nodes[2].Nodes.Add("Bing");
            treeView1.Nodes[2].Nodes.Add("Ask");
            treeView1.Nodes[2].Nodes.Add("Yahoo");
            treeView1.Nodes.Add("Website");
            treeView1.Nodes[3].Nodes.Add("webgeekresources.com");
            treeView1.Nodes[3].Nodes.Add("inettutor.com");
            treeView1.Nodes.Add("Colors");
            treeView1.Nodes[4].Nodes.Add("Primary");
            treeView1.Nodes[4].Nodes[0].Nodes.Add("Blue");
            treeView1.Nodes[4].Nodes[0].Nodes.Add("Red");
            treeView1.Nodes[4].Nodes[0].Nodes.Add("Yellow");
            
        }
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
           
        }

        private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            MessageBox.Show("Selected :" + treeView1.SelectedNode.Text);
        }       
    }
}
, , , , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.