Treeview and click on + to expand node

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

    Treeview and click on + to expand node

    Hi I have a little problem with Treeview expand.
    So I'll try to explain.

    I Have one node and some subnodes like this

    +Nodes1
    |------Subnodes 1
    |------Subnodes 2

    +Nodes2
    |------Subnodes 3
    |------Subnodes 3

    and so on....
    Well if Nodes2 is selected, and I'll click on + Nodes1,in the
    AfterExpand and AfterCollapse event I'll got handle for Nodes2 (the
    selected one) and not for the clicked one on + to expand.
    I need to get the handle for node wich i clicked + and no the selected
    one.
    Is there a way to do what I need?

    Many Thanks
  • kimiraikkonen

    #2
    Re: Treeview and click on + to expand node

    On May 15, 12:17 am, Marcolino <marco.pozzu... @gmail.comwrote :
    Hi I have a little problem with Treeview expand.
    So I'll try to explain.
    >
    I Have one node and some subnodes like this
    >
    +Nodes1
    |------Subnodes 1
    |------Subnodes 2
    >
    +Nodes2
    |------Subnodes 3
    |------Subnodes 3
    >
    and so on....
    Well if Nodes2 is selected, and I'll click on + Nodes1,in the
    AfterExpand and AfterCollapse event I'll got handle for Nodes2 (the
    selected one) and not for the clicked one on + to expand.
    I need to get the handle for node wich i clicked + and no the selected
    one.
    Is there a way to do what I need?
    >
    Many Thanks
    Marcolino,
    I tried to understand your issue and i hope adding these 2 events will
    do what you want:

    ' Select node that's expanded
    Private Sub TreeView1_After Expand(ByVal sender As System.Object, ByVal
    e As System.Windows. Forms.TreeViewE ventArgs) Handles
    TreeView1.After Expand
    TreeView1.Selec tedNode = e.Node
    End Sub

    ' Select node that's collapsed
    Private Sub TreeView1_After Collapse(ByVal sender As System.Object,
    ByVal e As System.Windows. Forms.TreeViewE ventArgs) Handles
    TreeView1.After Collapse
    TreeView1.Selec tedNode = e.Node
    End Sub

    and TreeView1 is your TreeView control of course.

    Hope this helps,

    Onur Güzel

    Comment

    • Armin Zingler

      #3
      Re: Treeview and click on + to expand node

      "Marcolino" <marco.pozzuolo @gmail.comschri eb
      Hi I have a little problem with Treeview expand.
      So I'll try to explain.
      >
      I Have one node and some subnodes like this
      >
      +Nodes1
      |------Subnodes 1
      |------Subnodes 2
      >
      +Nodes2
      |------Subnodes 3
      |------Subnodes 3
      >
      and so on....
      Well if Nodes2 is selected, and I'll click on + Nodes1,in the
      AfterExpand and AfterCollapse event I'll got handle for Nodes2 (the
      selected one) and not for the clicked one on + to expand.
      I need to get the handle for node wich i clicked + and no the
      selected one.
      Is there a way to do what I need?

      Works for me. I always get the expanded/collapsed node. How do you
      identify the node? It's in e.Node (e being one argument of the event
      handler).


      Armin

      Comment

      • Marcolino

        #4
        Re: Treeview and click on + to expand node

        On 14 Mag, 23:54, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
        On May 15, 12:17 am, Marcolino <marco.pozzu... @gmail.comwrote :
        >
        >
        >
        >
        >
        Hi I have a little problem with Treeview expand.
        So I'll try to explain.
        >
        I Have one node and some subnodes  like this
        >
        +Nodes1
        |------Subnodes 1
        |------Subnodes 2
        >
        +Nodes2
        |------Subnodes 3
        |------Subnodes 3
        >
        and so on....
        Well if Nodes2 is selected, and I'll click on + Nodes1,in the
        AfterExpand and AfterCollapse event I'll got handle for Nodes2 (the
        selected one) and not for the clicked one on + to expand.
        I need to get the handle for node wich i clicked + and no the selected
        one.
        Is there a way to do what I need?
        >
        Many Thanks
        >
        Marcolino,
        I tried to understand your issue and i hope adding these 2 events will
        do what you want:
        >
        ' Select node that's expanded
        Private Sub TreeView1_After Expand(ByVal sender As System.Object, ByVal
        e As System.Windows. Forms.TreeViewE ventArgs) Handles
        TreeView1.After Expand
        TreeView1.Selec tedNode = e.Node
        End Sub
        >
        ' Select node that's collapsed
        Private Sub TreeView1_After Collapse(ByVal sender As System.Object,
        ByVal e As System.Windows. Forms.TreeViewE ventArgs) Handles
        TreeView1.After Collapse
        TreeView1.Selec tedNode = e.Node
        End Sub
        >
        and TreeView1 is your TreeView control of course.
        >
        Hope this helps,
        >
        Onur Güzel- Nascondi testo tra virgolette -
        >
        - Mostra testo tra virgolette -
        Hi All.
        I solved. Thanks for your suggestions.

        --Marco

        Comment

        • kimiraikkonen

          #5
          Re: Treeview and click on + to expand node

          On May 15, 2:18 am, Marcolino <marco.pozzu... @gmail.comwrote :
          On 14 Mag, 23:54, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
          >
          >
          >
          On May 15, 12:17 am, Marcolino <marco.pozzu... @gmail.comwrote :
          >
          Hi I have a little problem with Treeview expand.
          So I'll try to explain.
          >
          I Have one node and some subnodes like this
          >
          +Nodes1
          |------Subnodes 1
          |------Subnodes 2
          >
          +Nodes2
          |------Subnodes 3
          |------Subnodes 3
          >
          and so on....
          Well if Nodes2 is selected, and I'll click on + Nodes1,in the
          AfterExpand and AfterCollapse event I'll got handle for Nodes2 (the
          selected one) and not for the clicked one on + to expand.
          I need to get the handle for node wich i clicked + and no the selected
          one.
          Is there a way to do what I need?
          >
          Many Thanks
          >
          Marcolino,
          I tried to understand your issue and i hope adding these 2 events will
          do what you want:
          >
          ' Select node that's expanded
          Private Sub TreeView1_After Expand(ByVal sender As System.Object, ByVal
          e As System.Windows. Forms.TreeViewE ventArgs) Handles
          TreeView1.After Expand
          TreeView1.Selec tedNode = e.Node
          End Sub
          >
          ' Select node that's collapsed
          Private Sub TreeView1_After Collapse(ByVal sender As System.Object,
          ByVal e As System.Windows. Forms.TreeViewE ventArgs) Handles
          TreeView1.After Collapse
          TreeView1.Selec tedNode = e.Node
          End Sub
          >
          and TreeView1 is your TreeView control of course.
          >
          Hope this helps,
          >
          Onur Güzel- Nascondi testo tra virgolette -
          >
          - Mostra testo tra virgolette -
          >
          Hi All.
          I solved. Thanks for your suggestions.
          >
          --Marco
          Glad it worked!

          Thanks,

          Onur

          Comment

          Working...