C# Add Node To TreeView

How To Insert A New Node To TreeView Using C#

add node to treeview using c#



In this C# Tutorial we will see How To Insert A New Node To TreeView From TextBox And ComboBox On Button Click Event In CSharp Programming Language And Visual  Studio Editor.




Project 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.Threading.Tasks;
using System.Windows.Forms;

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

        private void button1_Click(object sender, EventArgs e)
        {
            TreeNode node = new TreeNode(textBox1.Text);
            treeView1.Nodes.Add(node);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            TreeNode node = new TreeNode(comboBox1.SelectedItem.ToString());
            treeView1.SelectedNode.Nodes.Add(node);
        }
    }
} 

OutPut:

insert node into treeview in c#




Share this

Related Posts

Previous
Next Post »

1 comments:

comments
19 mars 2019 à 00:49 delete

This is so old video, the same code and concept not working in VS 2017.

thankyou.

Reply
avatar