SpeakComputers.com
Home
Software
Electronics
Desktop Computers
Laptops
Games
Handheld Devices
Mobile Phones
Cameras
Camcorders
Printers
Books
Software Downloads 2012 Software Mac Software Security Student Editions Windows 7 Office 2010
ASP.NET C# VB.NET C++ .NET Infragistics DevComponents

TreeView Control.

The Windows TreeView control is used to display a hierarchical collection or list of items. An example is commonly seen with Windows explorer.


Namespace: System.Windows.Forms
Assembly: Systems.Windows.Forms.dll

using System.Windows.Forms;
Calling: System.Windows.Forms.TreeView


Creating a new System.Windows.Forms.TreeView control.
TreeView treeView1 = new TreeView();

Adding the TreeView control to a Windows form.
this.Controls.Add(treeView1);

Placing the TreeView on the form at a specific location.
treeView1.Location = new Point(50, 50);

To add nodes to the TreeView control.
for (int i = 0; i < 20; i++) { TreeNode treeNode1 = new TreeNode(); treeNode1.Text = "TreeNode " + i.ToString(); this.treeView1.Nodes.Add(treeNode1); }

To add an event to determine which treenode has been selected.
this.treeView1.AfterSelect+=new TreeViewEventHandler(treeView1_AfterSelect);

To respond to the treenode which has been selected.
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { MessageBox.Show(e.Node.Text); }

To remove a selected TreeNode from the TreeView.
First we make sure that a TreeNode is selected, then we remove that TreNode from the TreeView.
if (this.treeView1.SelectedNode != null)
{
TreeNode treeNode = (TreeNode)this.treeView1.SelectedNode;
this.treeView1.Nodes.Remove(treeNode);

Computer Security
AntiVirus Software
Internet Security
Parental Controls
Backup & Recovery
Computer Protection
Anti Malware
Photo & Video
Photo & Video Editing
Video Music
Desktop Publishing
Professional Design
Home Publishing
Clipart
Business & Accounting
Accounting
Payroll
Check Printing
TAX
H&R Block
Microsoft Office
Design
Graphic Design
Home Design
Garden Design
Interior Design
Computer Aided Design
3D Design
Students & Teacher
Adobe
Microsoft Office
Dragon Naturally Speaking
Corel Draw
Serif
Student/Teacher Software
Copy Right 2006 SpeakComputers.com - All Rights Reserved.
Home About Privacy Policy Resouces