SpeakComputers.com online store
Electronics Software Computers Handhelds Laptops and Tablets Mobile Phones Digital Cameras Camcorders Games Music Books Sport Mens and Womens Watches Power Tools Household appliances

PRODUCTS

Software Downloads 2012 Software Mac Software Security Student Editions Windows 7 Office 2010

C++ TreeView Control.

The C++ 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
System.Windows.Forms (in system.windows.forms.dll)

Creating an new C++ Windows forms TreeView.
TreeView^ treeview = gcnew TreeView;

Creating the first TreeNode for the TreeView.
TreeNode^ tn1 = gcnew TreeNode;
tn1->Text = "Computers";

Adding the first TreeNode to the TreeView control.
treeview->Nodes->Add(tn1);

Creating TreeNode sub items to add to the first TreeNode.
TreeNode^ tn2 = gcnew TreeNode;
tn2->Text = "DELL";

TreeNode^ tn3 = gcnew TreeNode;
tn3->Text = "HP";

TreeNode^ tn4 = gcnew TreeNode;
tn4->Text = "SONY";

Adding the TreeNode sub items to the first TreeNode.
tn1->Nodes->AddRange(gcnew cli::array<TreeNode^>(3) {tn2, tn3, tn4});

Adding the TreeView Control to the Form.
this->Controls->Add(treeview);

Setting the selected TreeNode.
treeview->HideSelection = false;
treeview->SelectedNode = treeview->Nodes[0]->Nodes[1];

C++ TreeView control Tutorial.
Home About Privacy Policy Resouces Search

Copy Right 2006 SpeakComputers.com - All Rights Reserved.