Colorize nodes in the Table of Contents

Posted by: bagattini on 3 August 2023, 7:07 pm EST

  • Posted 3 August 2023, 7:07 pm EST

    I’m the process of upgrading from ActiveReports7 to ActiveReports17 an old codebase.

    So far, it’s being pretty much a plug-and-play experience. I have an issue on my build server (I’ve made a separate post here: https://www.grapecity.com/forums/activereports/activereports-licensing-on-a-build-server#69415 ) but from the code and compatibility perspective I have just one piece of code that doesn’t work anymore, related to the colorization of my TOC.

    In the previous iteration, I had a little dirty piece of code gaining access to underlying treeview:

                //example from: http://arhelp.grapecity.com/groups/topic/default-table-of-contents-to-collapsed/
                TocView tocView = null;
                var controls = _viewer.Controls.Find("SidebarView", true);
                var sidebarView = controls[0] as SidebarView;
    
                controls = sidebarView.Controls.Find("ContentPanel", true);
                var contentPanel = controls[0];
    
                foreach (Control control in contentPanel.Controls)
                {
                    if (((SidebarTabs)control.Tag) == SidebarTabs.Toc)
                        tocView = ((TocView)control);
                }

    after getting the TocView object I was able to iterate on the nodes and call a method to paint the nodes in different colors under some circumstances.

                foreach (TreeNode node in tocView.Nodes)
                {
                    this.ColorizeTocRecursive(node);
                }

    I still have a reference to an old post in a comment, but it’s now a dead link.

    TocView is now private, so I can’t access it anymore.

    I’m probably missing an higher level API that’s being introduced in the latest years that should let me do the same process in a clearer way. If anyone has an hint on that that would be great.

    Thanks in advance,

    Matteo

  • Posted 6 August 2023, 7:10 pm EST

    Hi Matteo,

    You can get the Toc Tree View by using the following API:

    var TocView=(viewer.Controls[0] as ToolStripContainer).ContentPanel.Controls[0].Controls[0].Controls[0].Controls[0].Controls[1] as TreeView;
    

    Please refer to the attached sample for modifying the TreeView Nodes.

    ProductCategoryReport.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels