Problems with Treeview.Nodes.Clear()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • juvi

    #1

    Problems with Treeview.Nodes.Clear()

    Hi, I have got a problem with Treeview.Nodes. Clear() under VB2005.

    When I have some nodes in my treeview and a force to clear() all nodes then
    it seems to work, because the nodes are not visible. But when I add new nodes
    and I want to look for a specific item then I only get the Items from the
    beginning --> something is not working with the clear() method.

    Please help me!?! juvi
  • Patrice

    #2
    Re: Problems with Treeview.Nodes. Clear()

    You perhaps kept a reference to an old node ?

    I'm using the clear method and didn't noticed anything for now...

    --
    Patrice

    "juvi" <juvi@discussio ns.microsoft.co m> a écrit dans le message de
    news:BAF6952D-F897-42E4-B373-B4427B5198C4@mi crosoft.com...[color=blue]
    > Hi, I have got a problem with Treeview.Nodes. Clear() under VB2005.
    >
    > When I have some nodes in my treeview and a force to clear() all nodes[/color]
    then[color=blue]
    > it seems to work, because the nodes are not visible. But when I add new[/color]
    nodes[color=blue]
    > and I want to look for a specific item then I only get the Items from the
    > beginning --> something is not working with the clear() method.
    >
    > Please help me!?! juvi[/color]


    Comment

    • juvi

      #3
      Re: Problems with Treeview.Nodes. Clear()

      How can I delete such references?

      "Patrice" wrote:
      [color=blue]
      > You perhaps kept a reference to an old node ?
      >
      > I'm using the clear method and didn't noticed anything for now...
      >
      > --
      > Patrice
      >
      > "juvi" <juvi@discussio ns.microsoft.co m> a écrit dans le message de
      > news:BAF6952D-F897-42E4-B373-B4427B5198C4@mi crosoft.com...[color=green]
      > > Hi, I have got a problem with Treeview.Nodes. Clear() under VB2005.
      > >
      > > When I have some nodes in my treeview and a force to clear() all nodes[/color]
      > then[color=green]
      > > it seems to work, because the nodes are not visible. But when I add new[/color]
      > nodes[color=green]
      > > and I want to look for a specific item then I only get the Items from the
      > > beginning --> something is not working with the clear() method.
      > >
      > > Please help me!?! juvi[/color]
      >
      >
      >[/color]

      Comment

      • Patrice

        #4
        Re: Problems with Treeview.Nodes. Clear()

        More precisely my thought would be that you might have kept in a variable a
        reference to the root node or something similar. If you delete then the
        treeview nodes and use this reference (perhaps adding it back to the
        treeview) you could likely have this behavior.

        Just double check that you don't use a variable that holds a reference to
        past nodes. Just make sure tthat you don't add to the new list nodes that
        were kept from the previous nodes...

        For exemple (not tested) :

        Dim Node as TreeNode
        Node=New TreeNode("A")
        Node.Nodes.Add( "B")
        TreeView1.Nodes .Add(Node)
        TreeView1.Nodes .Clear
        Node=New TreeNode("Other ") ' If commented you should likely still see nodes
        A and B child as you add backk an old node...
        TreeView1.Nodes .Add(Node)

        Good luck.
        --
        Patrice

        "juvi" <juvi@discussio ns.microsoft.co m> a écrit dans le message de
        news:B69E3083-B53B-41B7-9207-38F7F8D0FE9C@mi crosoft.com...[color=blue]
        > How can I delete such references?
        >
        > "Patrice" wrote:
        >[color=green]
        > > You perhaps kept a reference to an old node ?
        > >
        > > I'm using the clear method and didn't noticed anything for now...
        > >
        > > --
        > > Patrice
        > >
        > > "juvi" <juvi@discussio ns.microsoft.co m> a écrit dans le message de
        > > news:BAF6952D-F897-42E4-B373-B4427B5198C4@mi crosoft.com...[color=darkred]
        > > > Hi, I have got a problem with Treeview.Nodes. Clear() under VB2005.
        > > >
        > > > When I have some nodes in my treeview and a force to clear() all nodes[/color]
        > > then[color=darkred]
        > > > it seems to work, because the nodes are not visible. But when I add[/color][/color][/color]
        new[color=blue][color=green]
        > > nodes[color=darkred]
        > > > and I want to look for a specific item then I only get the Items from[/color][/color][/color]
        the[color=blue][color=green][color=darkred]
        > > > beginning --> something is not working with the clear() method.
        > > >
        > > > Please help me!?! juvi[/color]
        > >
        > >
        > >[/color][/color]


        Comment

        Working...