Below is the code which shows treeview control demo in c#. It has a treeview control and a label.
If we select any node on treeview, the label is showing named corresponding selected name of the node of treeview.
Below is the design view of the project:
Below is the source code of the project:
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 Treeview_control_demo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
label1.Text = treeView1.SelectedNode.Text.ToString();
TreeNode node = treeView1.SelectedNode;
}
}
}
Comments
Post a Comment