Get TreeView Node Text And Name In C#

How To Get Selected Node Text And Name From TreeView Using C#

Get TreeView Node Text / Name Using C#



In this C# Tutorial we will see How To Get The Selected TreeView Node Name Or Text And Display The Values Into A TextBox On treeView AfterSelect 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_Selected_Node : Form
    {
        public TreeView_Selected_Node()
        {
            InitializeComponent();
        }

        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            // get selected node text
            textBox1.Text = treeView1.SelectedNode.Text;

            // get selected node name
            textBox1.Text = treeView1.SelectedNode.Name;
        }
    }
}



OutPut:

Get Selected TreeView Node Text And Name In C#




Share this

Related Posts

Previous
Next Post »