Quick treeview question

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

    #1

    Quick treeview question

    Hi all,

    I have a treeview, each node's tag has a value. What I'm trying to do is
    when a user click on a child node, I want to get the parent's tag value.
    The problem i'm having is I don't know whether the selected node has a
    parent or not... could u help?

    Thanks~

    Kay


  • Scott M

    #2
    Re: Quick treeview question

    You could store a reference to the parent in the tag value. That would mean
    you'd have to create a custom class to hold the information that you need
    AND the parent.

    "Kay" <kk@micxsoft.co m> wrote in message
    news:O6CHp8G0FH A.2064@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Hi all,
    >
    > I have a treeview, each node's tag has a value. What I'm trying to do is
    > when a user click on a child node, I want to get the parent's tag value.
    > The problem i'm having is I don't know whether the selected node has a
    > parent or not... could u help?
    >
    > Thanks~
    >
    > Kay
    >[/color]

    Comment

    • Cor Ligthert [MVP]

      #3
      Re: Quick treeview question

      Kay,
      [color=blue]
      > I have a treeview, each node's tag has a value. What I'm trying to do is
      > when a user click on a child node, I want to get the parent's tag value.
      > The problem i'm having is I don't know whether the selected node has a
      > parent or not... could u help?
      >[/color]

      Sometimes it helps to look at MSDN, it is complete exact as you ask
      describted here.

      http://msdn.microsoft.com/library/de...arentTopic.asp

      I hope this helps,

      Cor


      Comment

      • Phill.  W

        #4
        Re: Quick treeview question

        "Kay" <kk@micxsoft.co m> wrote in message
        news:O6CHp8G0FH A.2064@TK2MSFTN GP09.phx.gbl...
        [color=blue]
        > The problem i'm having is I don't know whether the selected node
        > has a parent or not...[/color]

        Every Node has a Parent property that holds a reference to
        its immediate Parent Node, or nothing if it's at the root level,
        as in :

        If Not( tv.SelectedNode .Parent is Nothing ) then
        Zap( tv.SelectedNode .Parent.Tag )
        End If

        (I /think/ it's SelectedNode - might be SelectedItem; haven't got
        'Studio to hand at the moment).

        HTH,
        Phill W.


        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: Quick treeview question

          "Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> schrieb:[color=blue]
          > If Not( tv.SelectedNode .Parent is Nothing ) then
          > Zap( tv.SelectedNode .Parent.Tag )
          > End If
          >
          > (I /think/ it's SelectedNode - might be SelectedItem; haven't got
          > 'Studio to hand at the moment).[/color]

          It's actually 'SelectedNode' :-).

          --
          M S Herfried K. Wagner
          M V P <URL:http://dotnet.mvps.org/>
          V B <URL:http://classicvb.org/petition/>

          Comment

          • Kay

            #6
            Re: Quick treeview question

            Thanks a lot guys!

            Cor thanks for remind me that, I tried the VS help (looked into the parent
            property) but I didn't get what I need, now I know the online version is
            different from the VS help!


            "Kay" <kk@micxsoft.co m> wrote in message
            news:O6CHp8G0FH A.2064@TK2MSFTN GP09.phx.gbl...[color=blue]
            > Hi all,
            >
            > I have a treeview, each node's tag has a value. What I'm trying to do is
            > when a user click on a child node, I want to get the parent's tag value.
            > The problem i'm having is I don't know whether the selected node has a
            > parent or not... could u help?
            >
            > Thanks~
            >
            > Kay
            >[/color]


            Comment

            • Cor Ligthert [MVP]

              #7
              Re: Quick treeview question

              Kay,

              I never use the inbuild help anymore.

              Here is the other one, sometimes better, sometimes worse.



              :-)

              Cor


              Comment

              Working...