I have treeview in windowsform application when searching for node is performed I need to hide all the remaining node and I need to show only the searched node and its parent .like
grandParent
Parent1
child1
child2
child3.
parent2
child4
child5
if the searched node is child 3 i need to show the out put as..
grandParent
Parent1
child3
all auother are to be Hide.
Unfortunately (as far as I know) if you are using a WinForms TreeView control then hiding nodes is not as simple as setting the IsVisible property (due to the fact that the property is read only).
The only way of hiding nodes is to remove them from the Nodes collection.
This means displaying them again would require you to keep track of their location within the tree hierarchy to be able to restore them.
The following code seems to do what you require:
Hope this helps you.
I notice you are a new user, If this or any other questions you ask on the site provide the answers you are looking for remember to accept the answers.
See the following for more information: How does accepting an answer work?