Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6884213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:28:45+00:00 2026-05-27T05:28:45+00:00

I have a TreeView in my a C# winform. I would like to be

  • 0

I have a TreeView in my a C# winform. I would like to be able to add a search functionality through a search box.
Basically as the user types in letters (I’m guessing on the _TextChanged event), I show only the nodes that contain childnodes with the inputed letters…

My TreeView contains 53 parent nodes for a total of over 15000 Nodes so I need something a bit performant. I build my TreeView from a csv that I load into a DataTable and then make queries on to get the Parent nodes with associated child nodes…

UPDATE

I have an idea.
The final aim is that when a user doubleclicks on a child node it gets added to a listView.

I had first implemented this search function in a simple list view where I didn’t separate my data into categories.

My idea is that once the user starts typing in things, I turn off my Tree view and show the list view instead…

I’ll try and implement and see what it gives performance wise… Any critics on this idea are welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:28:46+00:00Added an answer on May 27, 2026 at 5:28 am

    Finally this is what I did, it suits my requirements.
    I first make a copy of my TreeView and store into fieldsTreeCache. I then clear the fieldsTree. I then search through the cache and add any node containing my search parameter to the fieldsTree. Note here that once you search, you no longer have the parent nodes that show. You just get all of the end nodes. I did this because if not I had 2 choices:

    • Expand all the parent nodes containing childs that match but then it was slow and one parent might have 50 children which isn’t great visually.
    • Not expand the parent nodes but then you just get the categories and not the children nodes that you’re searching for.

      void fieldFilterTxtBx_TextChanged(object sender, EventArgs e)
      {
          //blocks repainting tree till all objects loaded
          this.fieldsTree.BeginUpdate();
          this.fieldsTree.Nodes.Clear();
          if (this.fieldFilterTxtBx.Text != string.Empty)
          {
              foreach (TreeNode _parentNode in _fieldsTreeCache.Nodes)
              {
                  foreach (TreeNode _childNode in _parentNode.Nodes)
                  {
                      if (_childNode.Text.StartsWith(this.fieldFilterTxtBx.Text))
                      {
                          this.fieldsTree.Nodes.Add((TreeNode)_childNode.Clone());
                      }
                  }
              }
          }
          else
          {
              foreach (TreeNode _node in this._fieldsTreeCache.Nodes)
              {
                  fieldsTree.Nodes.Add((TreeNode)_node.Clone());
              }
          }
          //enables redrawing tree after all objects have been added
          this.fieldsTree.EndUpdate();
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So in my project i would like have a nice treeview that has images.
I have a TreeView which i build up in code recursively. I would like
I have a winform with a listbox and a treeview. Once my listbox is
I have a treeview (winforms) which have different item types on it. I have
I have a TreeView control in a Winforms app, and basically the objective is
I have a treeview with nodes like this: Foo (1234), and want to allow
In my winform application I have a treeview. To give the idea that a
I have a treeview control. I use keyboard to navigate through nodes. I want
I have some TreeView's in my winform application. I am trying to make mass
I have TreeView Populating from Database And I am Trying to detect the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.