[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 364
  • Last Modified:

TreeView: Checked Node => Selected Node

I have a TreeView control in an app that works just fine, so far.

I am presently adding a CheckBox to the control to permit the user to select one or many nodes for "processing".
Currently, I can determine which nodes are checked by simply walking the tree (top-to-bottom) and testing the ".Checked" property...after they are already selected (via a separate button click).

Problem:

I want react to the actual NodeCheck event, but I am not able to determine the CurrentNode.  "Checking" a node does not actually SELECT the node.

Question:

Is there a way to determine the CHECKED node without walking down the tree and testing the ".Checked" property?


Thanks!
0
markp99
Asked:
markp99
  • 5
  • 3
1 Solution
 
rockiroadsCommented:
Image if your treeview was called tvDB, u should be able to use the NodeClick handler


Private Sub tvDB_NodeClick(ByVal Node As Object)
    If Node.Text = Node.Key Then
        msgbox = "Top Root"
    Else
        Msgbox "Node.Text = " & Node.Text & vbcrlf & "Key is " & Node.Key
    End If
End Sub
0
 
rockiroadsCommented:
urm, perhaps NodeClick may not work for what you want
Try it, see if you get a msgbox appearing


Can I suggest u try the other handlers?

the other one which checks for expansion is _Expand

there is also NodeCheck

0
 
markp99Author Commented:
Thanks rr,

I am already trapping the NodeCheck event, but this does not seem to provide the actual Node info (thus my question).

The NodeClick event is not triggered by the NodeCheck event.

/scratching head
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
markp99Author Commented:
Dang it,

It's always EASIER than I think it should be:

    Private Sub TreeView_NodeCheck(ByVal Node As Object)
        If Node.Checked Then
            MsgBox "Node " & Node.Text & " was checked"
        Else
            MsgBox "Node " & Node.Text & " was unchecked"
        End If
    End Sub


markp99
0
 
rockiroadsCommented:
cool, ok, regarding the Expand handler

this should also work

Private Sub tvDB_Expand(ByVal Node As Object)
    MsgBox "Selected Node " & Node.Text
End Sub

to check if node has been expanded, this should work also

    If Node.Expanded = True Then



0
 
rockiroadsCommented:
bear in mind, Expand is only when you click on the + symbol
but I guess u already knew that!
0
 
markp99Author Commented:
I'll accept rr's comments, though my final solution was found elsewhere.

As noted above:

   Private Sub TreeView_NodeCheck(ByVal Node As Object)
        If Node.Checked Then
            MsgBox "Node " & Node.Text & " was checked"
        Else
            MsgBox "Node " & Node.Text & " was unchecked"
        End If
    End Sub
0
 
rockiroadsCommented:
thanks for the acceptance, but you know if you feel one has not provided you with a satisfactory answer or you have found the solution yourself, u have the right to request a refund and close the question - u just need to post in the community support section.

but eh, glad its all working for you though. Good luck with the rest of your venture!
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now