Link to home
Start Free TrialLog in
Avatar of eyaltil
eyaltil

asked on

disable/visible a node in tree view

hi,
i m trying to disable ( or to change to visiable =false)
one node in a tree view.

there is no disable propery for nodes and the visiable property is read only in runtime.

is there any way to do it without removeing all the nodes (with tree.remove methode) and adding them from again without that one node.

tnx,
eyaltil.
Avatar of cerik
cerik

The simple solution is to use the something like the Sheridan Active treeview control, as this has an enabled property on a node object. The only thing to watch is the Expand event, since though the node is disabled it can still be expanded, thus you need to test or set expanded property to false in the Expand event.

Active treeview is at www.sheridan.com, and costs a bit (US$195) but has some neat stuff

Otherwise, you could try set the nodes tag property and test the tag at each node event like, not super elegant, but it does work:
 
TreeView1.Nodes(3).Tag = "1"

Private Sub TreeView1_Expand(ByVal Node As ComctlLib.Node)
If Node.Tag = "1" Then Node.Expanded = False
End Sub

and

Private Sub TreeView1_NodeClick(ByVal Node As ComctlLib.Node)
If Node.Tag = "1" Then Exit Sub
End Sub

etc....
ASKER CERTIFIED SOLUTION
Avatar of cymbolic
cymbolic

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eyaltil

ASKER

does he has the visible propery too?

does it avaliable in run time (the reguler control has this propery but it read only in run time)
No the Sheridan one has the same visible property as the MS treeview, and seems to work the same way.

As to cymbolic's answer.

Yes the sheridan controls were buggy and no they do not like moveing from VB 4 to VB 5, but then again there were quiet a few problems with that move from a couple of 3rd party OCX's (I won't even mention Microsoft). But we have been working with the treeview for a while, and it does not seem to bad, especialy if you update with the bug patchs from Sheridan,( the ActiveToolbar is also quite nice, but I cannot comment on its stability yet.)


 
Just one other thing, cymbolic is correct in that if you have MS treeview heavily intergrated then, it would be better to try a work around.

 I also I fooled around with a hidden treeview to store the node and subnodes so that you can easily replace them back into the main treeview later, so this may be another way to go if you have a big complex sub structure under the node you wish to hide.