Results 1 to 6 of 6

Thread: checking treeview nodes

  1. #1
    bcbcneau is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Mar 2016
    Posts
    4
    Reputation
    0

    checking treeview nodes

    I have a tree view with to level nodes : parent and childs , and there are some childs which have the same name , and i want
    to do :
    if i check any node in treeview , check all the nodes which has the same name of checked node in vb net 2010.
    Can you help.

  2. #2
    IanRyder is offline VB.NET Forum All-Mighty
    .NET Framework
    .NET 4.0
    Join Date
    Sep 2012
    Location
    Healing, NE Lincs, UK
    Posts
    1,128
    Reputation
    745
    Hi,

    Have a look at the TreeView.AfterCheck Event that demonstrates how to recursively check all child nodes of a Parent node that was clicked in the TreeView. All you need to do now to complete your task is to add an If statement at the correct point to decide whether you need to check a particular node or not depending on the current node selected:-

    TreeView.AfterCheck Event

    Hope that helps.

    Cheers,

    Ian

  3. #3
    bcbcneau is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Mar 2016
    Posts
    4
    Reputation
    0
    HiI failed to do that , I get this error"can,t evaluate this expression:node.checked=true"Can you help by a simple example if you pleaseThank you

  4. #4
    IanRyder is offline VB.NET Forum All-Mighty
    .NET Framework
    .NET 4.0
    Join Date
    Sep 2012
    Location
    Healing, NE Lincs, UK
    Posts
    1,128
    Reputation
    745
    Hi,

    The example in the link I provided is a complete code snippet which is just missing your If statement so I am not sure how providing another example will help? Show us the actual code that has caused this error that you have got and we should be able to help you fix that in preparation for solving the complete task.

    Cheers,

    Ian

  5. #5
    bcbcneau is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Mar 2016
    Posts
    4
    Reputation
    0
    HiI will try myself to solve the problem so I understand more and exceed my skills , after that I will tell you what the results I get , I think the problem is if statement as you told me , so let me tryThank you

  6. #6
    bcbcneau is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Mar 2016
    Posts
    4
    Reputation
    0
    Hi
    I am failing in solving the problem and trying to use the code of after select events to color the nodes that have same text with red which is working good but it is not working with after check events, these are two codes
    In afterselect:
    Dim i as integer
    For i =o to treeview1.nodes.count-1
    For each y as treenode in treeview1.nodes(i).nodes
    If y.isselected then
    Y.forecolor=color.red
    Dim n as integer
    For n= i+1 to treeview1.nodes.count-1
    For each z as treenode in treeview1.nodes(n).nodes
    If z.text=y.text then
    Z.forecolor=color.red
    End if
    Next
    Next
    End if
    Next
    Next


    In aftercheck :
    Dim i as integer
    For i =0 to treeview1.nodes.count-1
    For each y as treenode in treeview1.nodes(i).nodes
    If y.checked= true then
    Dim n as integer
    For n=i+1 to treeviewr.nodes.count-1
    For each z as treenode in treeview1.nodes(n).nodes
    If z.text=y.text then
    Z.checked=true
    End if
    Next
    Next
    End if
    Next
    Next

    Can you help?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •