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

  • Home
  • SEARCH
  • 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 1010937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:09:34+00:00 2026-05-16T09:09:34+00:00

Tree View control’s AfterCheck event checks all child nodes below it and enables the

  • 0

Tree View control’s AfterCheck event checks all child nodes below it and enables the Run button if something is checked.

1346 void TreeNode_AfterCheck(object sender, TreeViewEventArgs e) {
1347   if (!e.Node.Checked) return;
1348   foreach (TreeNode sub in e.Node.Nodes) {
1349     sub.Checked = e.Node.Checked;
1350   }
1351   RunButton.Enabled = IsANodeChecked();
1352 }

1429 static bool IsANodeChecked(TreeNode node) {
1430   if (node.Checked) return true;
1431   foreach (TreeNode sub in node.Nodes) {
1432     if (IsANodeChecked(sub)) {
1433       return true;
1434     }
1435   }
1436   return false;
1437 }

Checking the root node when there are 4881 sub nodes will hang the GUI for about 7 seconds.

I only need to call IsANodeChecked (on Line 1351) once, but I don’t know how to disable it until after all of the tree nodes have been processed.

And I do not want to have a timer on my form devoted to monitoring this.

Does anyone see a simple/obvious solution?

  • 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-16T09:09:35+00:00Added an answer on May 16, 2026 at 9:09 am

    These ideas where helpful, but I used something different that worked by adding a single boolean variable:

    bool _treeNodeFirst = false;

    …and a Before Checked event that temporarily modifies the Back Color on the control to serve as a flag for the control that started the chain of events:

    1273 void TreeNode_BeforeCheck(object sender, TreeViewCancelEventArgs e) {
    1274   if (!_treeNodeFirst) {
    1275     _treeNodeFirst = true;
    1276     e.Node.BackColor = Color.Silver;
    1277   }
    1278 }
    
    1346 void TreeNode_AfterCheck(object sender, TreeViewEventArgs e) {
    1347   if (e.Node.Checked) {
    1348     foreach (TreeNode sub in e.Node.Nodes) {
    1349       sub.Checked = e.Node.Checked;
    1350     }
    1351   }
    1352   if (e.Node.BackColor == Color.Silver) {
    1353     e.Node.BackColor = Color.Empty;
    1354     RunButton.Enabled = IsANodeChecked();
    1355     _treeNodeFirst = false;
    1356   }
    1357 }
    
    1429 static bool IsANodeChecked(TreeNode node) {
    1430   if (node.Checked) return true;
    1431   foreach (TreeNode sub in node.Nodes) {
    1432     if (IsANodeChecked(sub)) {
    1433       return true;
    1434     }
    1435   }
    1436   return false;
    1437 }
    

    This seems to be the best way (that I can see right now) to ensure that IsANodeChecked(TreeNode) is only run once when a group of nodes is selected all at once.

    I do, however, really like Jimmy Hoffa’s idea of using a count, though. I will probably add that to my code.

    Thanks to all!
    ~Joe

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

Sidebar

Related Questions

I'm looking for a horizontal tree view control that creates nodes in the following
Anyone know where I can get a control like the Multi-column Tree-View in WPF?
I want my tree view control to show an item with a folder icon
I have a tree view control which I have to bind a dataset with
MSDN Says: A tree-view control uses memory that is allocated from the heap of
I have created a custom tree view control in .NET to display directories. What
ok can someone tell me the best tree view control in jquery? apart from
I am trying to load an XML file into a tree view control, edit
I have a web application where I am using asp.net tree view control to
I have web page in ASP.NET. I have created Tree View control with jQuery.

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.