|
|
|
|
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];
|
|
|
|
|