Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Various Treeview questions

Status
Not open for further replies.

UHNSTrust

Technical User
Dec 2, 2003
262
0
0
GB
I am new to using the treeview control. Can anybody help with the following?

1) How do you make the currently selected nodes text Bold or a different colour? (because the highlighting of a node disappears when the treeview control loses focus)
2) On the On-Click event of a node how can you tell if the node clicked is the first child node of that particular parent node?
3) When you press the + it drops the child nodes down. How can you force the focus to go to the first child node? And also to force the on-click event of the child node?

Hopefully somebody can point me in the right direction.

Thanks in advance.

Jonathan
 
I do not have Access on this computer so I am doing this from memory.
1) look at the node properties in the object browser
private sub XTree nodeClick(selectedNode as object)
selectedNode.forecolor = vbGreen

end sub

not sure on the bold, but I guess it is something like
selectedNode.fontBold = true
check the properties
2) The first sibling returns the first node in a level
private sub XTree nodeClick(selectedNode as object)
if selectedNode is selectedNode.firstSibling
end sub

you need to use "is" not "=" because you are comparing two objects.
3) The treeview has an expanded event. The child property of the node is the first child. So something lik" e

private XTree expanded(node as object)
node.child.selected = true
end sub
 
To unbold, or uncolor a node I would keep a public variable to keep track of the last node that you selected so that you can go back and recolor it black.

public lastSelected as string

private sub XTree nodeClick(selectedNode as object)
selectedNode.forecolor = vbGreen
if not lastSelected = "" then
xtree.nodes(lastSelected).forecolor = vbBlack
end if
lastSelected = selectedNode.key
end sub

In the above example I saved the key, but I could as easily dimensioned my variable as a node and save the node. Then change the if to see if lastSelected is nothing.
 
Hi MAjP.

Thanks for your help. Keep forgetting to look at the object browser!!

Jonathan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top