Missing the 'Expandable' TreeNode property

Discussion in 'Microsoft Dot NET Framework Forms' started by Guest, Mar 11, 2005.

  1. Guest

    Guest Guest

    The MSDN has an article titled:
    "HOW TO: Dynamically Add Nodes to a TreeView WebBrowser Control by Using
    Visual C# .NET".
    The article exploits a property of the TreeNode control called 'Expandable'.
    However, the property is available only for the Web Controls, and to my
    surprise I couldn't find it among the TreeNode Windows Forms properties.
    This Expandable property is crucial if you want to develop a smart, dynamic
    tree view which doesn't load all the data at once, but does it automatically
    as the user requests to expand the node.
    This is especially important if you want to bind the tree view to a database
    which can contain thousands of rows and you don't want to load all the nodes
    if the user doesn't even request it.
    Without the Expandable property the node doesn't have the ability to expand
    if you don't feed the sub-nodes during the tree creation. In other words the
    node doesn't have the 'plus' box to trigger the 'Expand' request. If the
    subnodes are supposed to be provided only on the expand request, then you are
    stuck.
    Is there any workaround for this problem?
    Thanks
    Cezar
     
    Guest, Mar 11, 2005
    #1
    1. Advertisements

  2. Guest

    Tobin Harris Guest

    "Cezar" <> wrote in message
    news:...
    > The MSDN has an article titled:
    > Without the Expandable property the node doesn't have the ability to
    > expand
    > if you don't feed the sub-nodes during the tree creation. In other words
    > the
    > node doesn't have the 'plus' box to trigger the 'Expand' request. If the
    > subnodes are supposed to be provided only on the expand request, then you
    > are
    > stuck.
    > Is there any workaround for this problem?
    > Thanks
    > Cezar


    I have a work around that I've used in several programs (for example, see
    the lazy-loading database tree view in SqlBuddy (sqlbuddy.sourceforge.net).

    The work around is to add a dummy node to each parent node that you want to
    lazy load. This forces the "+" to appear on these parent nodes. Then, in the
    afterexpand event, first see if there is a "dummy" node under the parent. If
    so then delete it (you don't want the user to see it). Then do your lazy
    loading to add the real child nodes. A nice side-effect is that, if there
    aren't any child nodes to lazy load, the "+" will dissappear (since the
    dummy has been removed).

    Hope this helps

    Tobin
     
    Tobin Harris, Mar 13, 2005
    #2
    1. Advertisements

  3. Guest

    Guest Guest

    Thank you very much for your answer.
    This is exactly what I did. The exception is that if there are no child
    nodes I don't remove the dummy and simply let it show. The dummy has no text,
    just a broken line ending in empty space making an impression of nothing to
    chose from.

    "Tobin Harris" wrote:

    > "Cezar" <> wrote in message
    > news:...
    > > The MSDN has an article titled:
    > > Without the Expandable property the node doesn't have the ability to
    > > expand
    > > if you don't feed the sub-nodes during the tree creation. In other words
    > > the
    > > node doesn't have the 'plus' box to trigger the 'Expand' request. If the
    > > subnodes are supposed to be provided only on the expand request, then you
    > > are
    > > stuck.
    > > Is there any workaround for this problem?
    > > Thanks
    > > Cezar

    >
    > I have a work around that I've used in several programs (for example, see
    > the lazy-loading database tree view in SqlBuddy (sqlbuddy.sourceforge.net).
    >
    > The work around is to add a dummy node to each parent node that you want to
    > lazy load. This forces the "+" to appear on these parent nodes. Then, in the
    > afterexpand event, first see if there is a "dummy" node under the parent. If
    > so then delete it (you don't want the user to see it). Then do your lazy
    > loading to add the real child nodes. A nice side-effect is that, if there
    > aren't any child nodes to lazy load, the "+" will dissappear (since the
    > dummy has been removed).
    >
    > Hope this helps
    >
    > Tobin
    >
    >
    >
     
    Guest, Mar 14, 2005
    #3
  4. Guest

    dilipkakadiya

    Joined:
    Nov 12, 2011
    Messages:
    2
    Likes Received:
    0
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ron Bullman

    TreeView with adjustable TreeNode height

    Ron Bullman, Jul 12, 2003, in forum: Microsoft Dot NET Framework Forms
    Replies:
    3
    Views:
    4,629
    yamingo2001
    May 15, 2008
  2. Howard Swope

    Property Grid Stops Expanding Expandable Properties

    Howard Swope, Jul 14, 2003, in forum: Microsoft Dot NET Framework Forms
    Replies:
    1
    Views:
    1,688
    Lion Shi
    Jul 16, 2003
  3. Charles

    Getting the Tag Property for each child treenode

    Charles, Nov 17, 2003, in forum: Microsoft Dot NET Framework Forms
    Replies:
    1
    Views:
    456
    Charles
    Nov 17, 2003
  4. Guest

    adding childnode in non expandable nodes

    Guest, Apr 29, 2004, in forum: Microsoft Dot NET Framework Forms
    Replies:
    4
    Views:
    231
    Guest
    May 3, 2004
  5. Guest

    set the parent property of a treenode in treeview control

    Guest, Apr 23, 2006, in forum: Microsoft Dot NET Framework Forms
    Replies:
    6
    Views:
    967
    Linda Liu [MSFT]
    Apr 26, 2006
Loading...

Share This Page