Solved

disable/visible a node in tree view

Posted on 1998-06-15
5
564 Views
Last Modified: 2006-11-17
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.
0
Comment
Question by:eyaltil
  • 3
5 Comments
 

Expert Comment

by:cerik
Comment Utility
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....
0
 
LVL 9

Accepted Solution

by:
cymbolic earned 120 total points
Comment Utility
You are correct in assuming that you would have to delete then add back treeview items to make them dissappear and reappear using the Microsoft supplied Treeview.  Of course this may present other problems, since the control will redraw to present the new picture.  I would say a better way would be to change the icon for the node, so that your user could visibly see that the node was no longer enabled.  That way you can use the icon property to intercept events for disabled nodes, and your user will get a clue that the other similar "iconed" nodes are disabled as well.

It's useless to attempt to make this control do something outside of its programmed methods.  You'll just waste a lot of time to no purpose.  There are however a number of third party treeview controls out there.  The problem is that in all I've looked at, once you've written your code to the MS treeview control, its a rewrite to use any other treeview.  Also, its a major effort to learn any of them, since the controls are so complex, tricky, and with so many properties and methods.

I have not personally been very pleased with the Sheridan controls.  They have seemed to me to be excessively buggy, and don't seem to make the trip between VB versions very well.

If contemplating a replacement treeview, look at www.vbxtras.com.  Be prepared to find that they are all nasty beasts to work with, particularly if you want to make them work outside of their native programmed methods.  Its enough effort to get any one of them working well, that you need to find one that is acceptable (MS's will do) and find ways around their limitations and work within the available methods.
0
 

Author Comment

by:eyaltil
Comment Utility
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)
0
 

Expert Comment

by:cerik
Comment Utility
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.)


 
0
 

Expert Comment

by:cerik
Comment Utility
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.

 
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now