Pogramatically Find TreeView Item in C#

Introduction

This blog gives a code example how to find and focus TreeView item at run time using c#, see the following code, you will come to your know the logic

foreach (object obje in this.filterableTreeview.Items)

{

      TreeViewItem TVI = (TreeViewItem)filterableTreeview.ItemContainerGenerator.ContainerFromItem(obje);

      if (TVI.Header.ToString().ToLower() == this.txtsearch.Text.ToLower())

{

    TVI.Background = Brushes.Red;

    TVI.IsExpanded = true;

}

    if (TVI.Items.Count > 0)

    this.Search(TVI);

}

 

X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now