How To Get Selected Node Text And Name From TreeView 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;
}
}
}