Thursday, 15 May 2014

ASP.NET - How to create TreeView with checkboxes programmatically


Watch this example on YouTube:
            TreeView tv = new TreeView();
            tv.ID = "TV1";
            tv.CollapseAll();
            tv.ExpandAll();
            tv.ShowCheckBoxes = TreeNodeTypes.All;  //ADD CHECKBOXES

            TreeNode tn = new TreeNode();
            tn.Text = "Node1";

            TreeNode tn2 = new TreeNode();
            tn2.Text = "Node2";

            TreeNode tnGrand = new TreeNode();
            tnGrand.Text = "grandchild";
            tn2.ChildNodes.Add(tnGrand);

            tv.Nodes.Add(tn);
            tv.Nodes.Add(tn2);
            form1.Controls.Add(tv);

No comments:

Post a Comment