TreeView bound to bindinglist with Load on Demand in Q1 2011

7 posts, 0 answers
  1. Sonya L
    Sonya L avatar
    36 posts
    Member since:
    Dec 2009

    Posted 12 Apr 2011 Link to this post

    Hello,
    Is it not possible to use the TreeView bound to a self-referencing BindingList with Load on Demand in Q1 2011?  If I bind the treeview to the binding list, no expand/collapse buttons show up on the last level.  In Q1 2010, I had the treeview loading certain levels on demand by handling NodeExpandedChanged, and adding items to the bindinglist.  Now, there is no expand/collapse button to do this.  Any advice would be appreciated.  Thanks!

    Sonya
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 15 Apr 2011 Link to this post

    Hi Sonya L,

    Thank you for this question.

    In this scenario you can use the new NodesNeeded event introduced in the last version of our RadTreeView control. More information you can found in our online documentation.

    The following code snippet describes an alternative solution:


    public
    partial class Form6 : Form
    {
        class LazyTreeNode : RadTreeNode
        {
            private bool loaded;
       
            public bool Loaded
            {
                get { return loaded; }
                set { loaded = value; }
            }
        }
       
        public Form6()
        {
            InitializeComponent();
            radTreeView1.ShowLines = true;
       
            using (radTreeView1.DeferRefresh())
            {
                for (int i = 0; i < 10; i++)
                {
                    radTreeView1.Nodes.Add("RootNode" + i.ToString());
                }
            }
        }
       
        private void radTreeView1_NodeExpandedChanged(object sender, Telerik.WinControls.UI.RadTreeViewEventArgs e)
        {
            LazyTreeNode node = e.Node as LazyTreeNode;
            if (node.Loaded)
            {
                return;
            }
       
            node.Nodes.BeginUpdate();
            for (int i = 0; i < 10; i++)
            {
                node.Nodes.Add("ChildNode" + i.ToString());
            }
            node.Nodes.EndUpdate();
            node.Loaded = true;
        }
       
        private void radTreeView1_CreateNode(object sender, Telerik.WinControls.UI.CreateTreeNodeEventArgs e)
        {
            e.Node = new LazyTreeNode();
        }
       
        private void radTreeView1_NodeFormatting(object sender, TreeNodeFormattingEventArgs e)
        {
            e.NodeElement.ExpanderElement.Visibility = Telerik.WinControls.ElementVisibility.Visible;
        }
    }

    This solution has a known issue concerning the indent of RadTreeNodes from different levels. We will address the issue in our upcoming service pack scheduled for the next week.

    Do not hesitate to contact us if you have more questions.

    Kind regards,
    Julian Benkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Sonya L
    Sonya L avatar
    36 posts
    Member since:
    Dec 2009

    Posted 20 Apr 2011 Link to this post

    What I really want to do is bind the treeview to a binding list, then when a node is expanded, add items to the binding list, and have them appear in the tree view.  This worked fine in q1 2010, but not in q1 2011.  Is this still possible?
  5. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 22 Apr 2011 Link to this post

    Hello Sonya L,

    The new version of RadTreeView control can not mix bound and unbound data mode. You can download Q1 2011 SP1 release and use the code snippet from the previous post as a solution. If you continue to experience the problems, please send me a sample project or some part of your real project. This will allow me to find the best solution for your case where a BindingList is used.

    All the best,
    Julian Benkov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Sonya L
    Sonya L avatar
    36 posts
    Member since:
    Dec 2009

    Posted 03 May 2011 Link to this post

    Is there a workaround for the indenting issue that still occurs in 2011 Q1 SP1?  it looks like my nodes without children are indented further to the right than the ones with children.  Also, it looks like the expander graphic is set to the minus (-) when I first load and display the tree, but the nodes aren't actually expanded.  Has anyone seen this happen before?  I'm still looking through my code to see what might be causing it, and working with the above example to get Load on Demand working (I'm not using NodesNeeded).  Thanks!
  7. Sonya L
    Sonya L avatar
    36 posts
    Member since:
    Dec 2009

    Posted 03 May 2011 Link to this post

    Please ignore the part about the expander graphic.  I think our custom theme may have it backwards.  Still need a workaround for the indention though.
  8. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 06 May 2011 Link to this post

    Hi Sonya L,

    Please find the answer in this forum thread:
    http://www.telerik.com/community/forums/winforms/treeview/treeview-indent-in-2011-q1-sp1.aspx

    Kind regards,
    Julian Benkov
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Back to Top
UI for WinForms is Visual Studio 2017 Ready