select all childs in a Treeview

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

    select all childs in a Treeview

    Hi group. Merry Xmas one and all!!!! I hope Santa brings you all something
    good. For me, I would be happy with some nice code!

    If I check a node in a treeview, how do I check all childs of that node? I
    wrote:


    Dim Child As TreeNode = Nothing

    For Each Child In myTreeView.Node s

    Child.Checked = True

    Next



    Now, as regular readers will know, collections are not my strong point. I
    know that I have not told VB which node I am referring to when I run this
    (the one I just checked is the one I want to refer to). What is missing in
    my code? Or is it completely rubbish!??!!

    --
    Bob Hollness

    -------------------------------------
    I'll have a B please Bob


  • Lloyd Sheen

    #2
    Re: select all childs in a Treeview

    The nodes of a treeview are in fact collections of collection. When you get
    the event for the check you will get a reference to the node which was
    checked. You then use the same construct as you have in your code but
    replace the myTreeView with the node that was checked.

    Hope this helps.

    Lloyd Sheen

    "Bob Hollness" <bob@blockbuste r.com> wrote in message
    news:ebUpq1d6EH A.2552@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Hi group. Merry Xmas one and all!!!! I hope Santa brings you all
    > something good. For me, I would be happy with some nice code!
    >
    > If I check a node in a treeview, how do I check all childs of that node?
    > I wrote:
    >
    >
    > Dim Child As TreeNode = Nothing
    >
    > For Each Child In myTreeView.Node s
    >
    > Child.Checked = True
    >
    > Next
    >
    >
    >
    > Now, as regular readers will know, collections are not my strong point. I
    > know that I have not told VB which node I am referring to when I run this
    > (the one I just checked is the one I want to refer to). What is missing
    > in my code? Or is it completely rubbish!??!!
    >
    > --
    > Bob Hollness
    >
    > -------------------------------------
    > I'll have a B please Bob
    >
    >[/color]


    Comment

    • Bob Hollness

      #3
      Re: select all childs in a Treeview

      this is exactly what I needed! thanks!

      --
      Bob Hollness

      -------------------------------------
      I'll have a B please Bob

      "Lloyd Sheen" <sqlguyremoveal lofthis@tostops pamhotmail.com> wrote in message
      news:LrKdnUQkD5 nPwVHcRVn-uQ@rogers.com.. .[color=blue]
      > The nodes of a treeview are in fact collections of collection. When you
      > get the event for the check you will get a reference to the node which was
      > checked. You then use the same construct as you have in your code but
      > replace the myTreeView with the node that was checked.
      >
      > Hope this helps.
      >
      > Lloyd Sheen
      >
      > "Bob Hollness" <bob@blockbuste r.com> wrote in message
      > news:ebUpq1d6EH A.2552@TK2MSFTN GP09.phx.gbl...[color=green]
      >> Hi group. Merry Xmas one and all!!!! I hope Santa brings you all
      >> something good. For me, I would be happy with some nice code!
      >>
      >> If I check a node in a treeview, how do I check all childs of that node?
      >> I wrote:
      >>
      >>
      >> Dim Child As TreeNode = Nothing
      >>
      >> For Each Child In myTreeView.Node s
      >>
      >> Child.Checked = True
      >>
      >> Next
      >>
      >>
      >>
      >> Now, as regular readers will know, collections are not my strong point.
      >> I know that I have not told VB which node I am referring to when I run
      >> this (the one I just checked is the one I want to refer to). What is
      >> missing in my code? Or is it completely rubbish!??!!
      >>
      >> --
      >> Bob Hollness
      >>
      >> -------------------------------------
      >> I'll have a B please Bob
      >>
      >>[/color]
      >
      >[/color]


      Comment

      Working...