0% found this document useful (0 votes)
12 views

Tree View

The document discusses populating a TreeView control in C# with a hierarchical structure. It shows code to add nodes for levels like "Développement informatique", "1 ére Année", and "Groupe A1". It also includes a button click handler that displays the selected node's text and full path in other controls for viewing the item's location.

Uploaded by

sami corea
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Tree View

The document discusses populating a TreeView control in C# with a hierarchical structure. It shows code to add nodes for levels like "Développement informatique", "1 ére Année", and "Groupe A1". It also includes a button click handler that displays the selected node's text and full path in other controls for viewing the item's location.

Uploaded by

sami corea
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Module 10 – Programmation Evénementielle C #

Partenaire en Compétence « Travaux Pratique »

TreeView

// **** Remplir le TreeView "les niveaux hiérarchiques"


private void Form2_Load(object sender, EventArgs e)
{
TreeNode tNode;
// **** Niveau 1
tNode = treeView1.Nodes.Add("Développement informatique");
// **** Niveau 2
treeView1.Nodes[0].Nodes.Add("1 ére Année");
// **** Niveau 3
treeView1.Nodes[0].Nodes[0].Nodes.Add("Groupe A1");
treeView1.Nodes[0].Nodes[0].Nodes.Add("Groupe B1");

treeView1.Nodes[0].Nodes.Add("2 ème Année");


treeView1.Nodes[0].Nodes[1].Nodes.Add("Groupe A2");
treeView1.Nodes[0].Nodes[1].Nodes.Add("Groupe B2");

tNode = treeView1.Nodes.Add("Infographie");
treeView1.Nodes[1].Nodes.Add("1 ére Année");
treeView1.Nodes[1].Nodes[0].Nodes.Add("Groupe A1");
}

private void button1_Afficher(object sender, EventArgs e)


{
//*** Affichage de lélement séléctionné
textBox1.Text = treeView1.SelectedNode.Text;
//*** Affichage de chemin de lélement séléctionné
label1.Text = "Chemin: " +treeView1.SelectedNode.FullPath.ToString();
}
Mr : A.TORBI

You might also like