Skip to content

Search in treeview - C#

Yossi Alaluf

Asked Feb 17, 2009, 9:26 PM EST1 answer
Share
LinkedInX
Hi,

I tryied to implement a recursive search in a tree without success.

For example my tree display 3 levels: root, parents and children. I need to return as result a new tree with only the children (and parets of course) that have  specific string in their names.

for example:

Company

                DEV

                                Yoni

                                Cris

                                Mark

                QA

                                Yossi

                                Alex

                                Serah

                                Danna

                QM

                                Josef

 

If I search for "yo"

The new tree should return:

 

Company

                DEV

                                Yoni

                QA

                                Yossi

Can anyone help me with this problem?

 

 

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Mahesh Chand
    0

    If you have a data source bound to the TreeView control, you can use the data source to find the matching items and probably create another data source with matching items and rebind your TreeView with this new data source.

    Alternatively, if your tree does not have lot of items (less than 100 is OK), loop through TreeView items and delete items that does not match with the keyword.

    0