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 6997227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:15:25+00:00 2026-05-27T20:15:25+00:00

I’m having a seriously annoying problem on which I’ve been spending a ridiculous amount

  • 0

I’m having a seriously annoying problem on which I’ve been spending a ridiculous amount of time on trying to resolved and still to no avail!!

Over the years, I’ve never used the standard treeview that comes with .NET as I’ve always used a third-party component but talking about a bad experience so far!!!

In short, I’m loading my drives and then when expanding a drive, I list folders, and so on… Nothing new here, but I’m having 2 major problems:

  1. When all branches are collapsed, it triggers the before and after expand event twice.. BeforeExpand x 2, then AfterExpand x 2.

  2. When multiple branches are expanded, it will trigger the event 2 for each expanded branches… It’s like I’m calling some sort of recursive code when I’m not… So for example,

Expand C -> Triggers BeforeExpand x 2, then AfterEvent x 2 – Leave it expanded

Expand E -> Triggers BeforeExpand x 2 for E, then AfterEvent x 2, then does it again for C – Leave E expanded.

Expand F -> Triggers BeforeExpand x 2 for F, then AfterEvent x 2, then does it again for E then C.

It doesn’t make sense!!

Code wise:

  1. Initialize the BeforeExpand and AfterExpand when my form initializes i.e.

        treeView1.BeforeExpand += new TreeViewCancelEventHandler(treeView1_BeforeExpand);
        treeView1.AfterExpand += new TreeViewEventHandler(treeView1_AfterExpand);
    
  2. When I expand a node, a background thread is called and either loads the drives or folders. From the background worker thread, I call a function, which handles the cross threading issue by calling a delegate so again, nothing special

I’m out of ideas as to what’s causing this bar the fact that it could be a bug on MS side, but I doubt it… It feels like a problem that just far too obvious.

I’m happy to post my code if needed as this was just a dummy test app I started and maybe you’ll spot something I’ve done wrong but I just can’t see what.

Hope someone has a clue as to what’s causing this.

Thanks.

Thierry.

  • 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-27T20:15:26+00:00Added an answer on May 27, 2026 at 8:15 pm

    I figured out what the problem was so I thought I’d share it in case this happens to anyone else!!

    This is insane but in the background worker thread, I called the treeview1.Sort() in the RunWorkerCompleted and this is what is causing the beforeExpand and afterExpand events to be called multiple times! Once removed, it behaved accordingly.

    I guess I will sort the folders first and then raised the delegate from the thread to update the UI with the sorted list.

    That’s it!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.