Recognize if .parent in a Treeview

Emperor

Board Regular
Joined
Mar 25, 2010
Messages
225
Hi all,

I have a Treeview control in a userform, now I need to execute code when dbblclicked an item. This is ofcourse no problem. However, I would like to execute a different code when the selected item is a parent, or a child.

Does anyone know how I can control this with VBA?

Thanks in advance!

Mathijs
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Code:
Private Sub Treeview1_NodeClick(ByVal Node As MSComctlLib.Node)

    If Not Node.Child Is Nothing Then
    [COLOR="Green"]'Clicked node is a parent.[/COLOR]
        MsgBox "Clicked node """ & Node.Key & """ is a parent."
    End If
    
    If Not Node.Parent Is Nothing Then
    [COLOR="Green"]'Clicked node is a child.[/COLOR]
        MsgBox "Clicked node """ & Node.Key & """ is a child."
    End If
    
    If Node.Parent Is Nothing And Node.Child Is Nothing Then
    [COLOR="Green"]'Clicked node is neither a parent or child[/COLOR]
        MsgBox "Clicked node """ & Node.Key & """ is not a parent or a child."
    End If
    
End Sub
 
Upvote 0
Thanks Alpha!

If you where a girl, arround 20 and attractive I would kiss you ^^, but statistics say your probably a dude, arround 40... so your loss ^^
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top