This is a migrated thread and some comments may be shown as answers.

TreeView bound to bindinglist with Load on Demand in Q1 2011

6 Answers 65 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Sonya L
Top achievements
Rank 1
Sonya L asked on 12 Apr 2011, 01:30 PM
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

6 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 15 Apr 2011, 11:24 AM
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
0
Sonya L
Top achievements
Rank 1
answered on 20 Apr 2011, 04:20 PM
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?
0
Julian Benkov
Telerik team
answered on 22 Apr 2011, 02:04 PM
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
0
Sonya L
Top achievements
Rank 1
answered on 03 May 2011, 04:35 PM
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!
0
Sonya L
Top achievements
Rank 1
answered on 03 May 2011, 07:33 PM
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.
0
Julian Benkov
Telerik team
answered on 06 May 2011, 12:33 PM
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.
Tags
Treeview
Asked by
Sonya L
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Sonya L
Top achievements
Rank 1
Share this question
or