private void AddRootB_Click(object sender, EventArgs e)
 {
     nodescount++;
     TreeNode tr = new TreeNode(string.Format("Node{0}", nodescount.ToString()));
     TypedTreeViewDisplayMember tvdm = new TypedTreeViewDisplayMember("", "");
     tr.Tag = tvdm;
     MainTree.Nodes.Add(tr);
     tvdm.NodeName = tr.Text;
     _tvdml.Add(tvdm);
     MainTree.SelectedNode = tr;
     AddChildB.Enabled = true;
     HiglightNode();
 }
 private void AddChildB_Click(object sender, EventArgs e)
 {
     if (MainTree.SelectedNode != null)
     {
         nodescount++;
         TreeNode tr = new TreeNode(string.Format("Node{0}", nodescount.ToString()));
         TypedTreeViewDisplayMember tvdm = new TypedTreeViewDisplayMember("", "");
         tr.Tag = tvdm;
         tvdm.NodeName = tr.Text;
         MainTree.SelectedNode.Nodes.Add(tr);
         (MainTree.SelectedNode.Tag as TypedTreeViewDisplayMember).ChildDisplayMembers.Add(tvdm);
         MainTree.SelectedNode = tr;
         HiglightNode();
     }
 }
        private void MakeBranch(TreeNode parentnode, TypedTreeViewDisplayMember tvdm)
        {
            TreeNode node = new TreeNode(tvdm.NodeName);
            node.Tag = tvdm;
            parentnode.Nodes.Add(node);
            nodescount++;

            if (tvdm.ChildDisplayMembers.Count > 0)
            {
                foreach (var subitem in tvdm.ChildDisplayMembers)
                    MakeBranch(node, subitem);
            }
        }