|
-
Dec 13th, 1999, 03:44 PM
#1
Thread Starter
Addicted Member
When using Treeview how do I find out if a node that I have selected is a Parent or a Child. Also if it is a Child how do I find the name of the Parent.
------------------
OmarSwan
Student
[email protected]
"Jesus Lives"
-
Dec 13th, 1999, 04:28 PM
#2
Lively Member
Put a treeview control on a form and paste this code in....
Option Explicit
Dim m_LastX As Single
Dim m_LastY As Single
Private Sub Form_Load()
TreeView1.Nodes.Add , , "Root", "Root"
TreeView1.Nodes.Add "Root", tvwChild, "child", "child"
End Sub
Private Sub TreeView1_Click()
Dim nodX As Node
Set nodX = TreeView1.HitTest(m_LastX, m_LastY)
If Not nodX Is Nothing Then
If nodX.Children > 0 Then
Debug.Print "Parent node"
End If
If Not nodX.Parent Is Nothing Then
Debug.Print "Child node"
Debug.Print "Parent key is " & nodX.Parent.Key
End If
End If
End Sub
Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
m_LastX = x
m_LastY = y
End Sub
-
Dec 13th, 1999, 07:06 PM
#3
Put this code on TreeView_NodeClick event:
Code:
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If Node.Parent Is Nothing Then
MsgBox "Node " & Node.Text & " is a root node."
Else
MsgBox "Node " & Node.Text & " is a child to " & Node.Parent.Text
End If
End Sub
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|