add Custom cotrol on node

how to add node and GridgroupingCntrol on each node in treeviewAdv at runtime .

1 Reply

SK Senthil Kumaran Rajan Syncfusion Team July 8, 2015 11:05 AM UTC

Hi Pravin,

Thank you for using Syncfusion products.

The reported requirement can be achieved by using Custom control property in TreeNodeAdv. Please refer the below code example.

Code Snippet[C#]:

   //To add the Parent node

   for (i = 0; i < TotalNodeCount; i++)

      {

          TreeNode = new TreeNodeAdv();

          TreeNode.Text = "node" + nodenumber.ToString();

          nodenumber++;

          this.treeViewAdv1.Nodes.Add(TreeNode);

       }


   //To Add child node

   foreach (TreeNodeAdv node in this.treeViewAdv1.Nodes)

      {

          TreeNode = new TreeNodeAdv();

          TreeNode.Text = "node" + nodenumber.ToString();

          nodenumber++;

          node.Nodes.Add(TreeNode);

       }


   //To add the GridGrouping Control as custom control.

    foreach (TreeNodeAdv node in Collect(this.treeViewAdv1.Nodes))

       {

            GridGroup = new GridGroupingControl();

            GridGroup.GridVisualStyles = GridVisualStyles.Metro;

            GridGroup.TopLevelGroupOptions.ShowCaption = false;

            if (node.CustomControl == null)

             {

                  node.CustomControl = GridGroup;

                  GridGroup.DataSource = dt;

                  node.CustomControl.Width = 300;

                  node.Height = 40;

             }

      }


We have also prepared a sample for your reference and it can be downloaded from the below location.

Sample Location : http://www.syncfusion.com/downloads/support/forum/119542/ze/TreeCustom-1373315669

Please refer the below Knowledge Base to add the custom control in TreeViewAdv.

KB Link : http://www.syncfusion.com/kb/4666/how-to-add-custom-controls-in-treeviewadv

Please let us know if you need further assistance.

Regards,
Senthil

Loader.
Up arrow icon