Results 1 to 2 of 2

Thread: treeview - determine type of node (child, parent)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 1999
    Location
    Greece
    Posts
    26
    Hi...I am working with the treeview ctrl... When I right click to its nodes, I want to be able to determine what type of node is selected... the root, a 1st level child, a 2nd level child ?? etc...
    Any ideas?

    Thank you...


  2. #2
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Hi,
    Try this:
    Code:
    Private Sub TreeView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
        'This will work as long as none your node
        'names contains the character "\"
        If Button = 2 Then 'Show on right mouse click
            Dim i As Integer
            Dim TV As String
            Dim Count As Integer
            TV = TreeView1.SelectedItem.FullPath
            For i = 1 To Len(TV)
                If Mid(TV, i, 1) = "\" Then Count = Count + 1
            Next i
            If Count = 0 Then
                MsgBox "This is a top-level node"
            Else
                MsgBox "This node is " & CStr(Count) & " levels into the structure"
            End If
        End If
    End Sub
    Hope this helps

    Shaun
    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

Posting Permissions

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



Click Here to Expand Forum to Full Width