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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:19:14+00:00 2026-06-15T20:19:14+00:00

I have a treeview with a list of items that are expandable. When the

  • 0

I have a treeview with a list of items that are expandable. When the user checks the checkbox for a parent node, I simulate checking the children nodes. However, the user can check any node (not just parent nodes). I want to distinguish the user’s first click, which triggers the node’s checkbox event, from the simulated checking of the children node’s checkboxes.

I want to distinguish the User’s click so I can save the state of the treeview before it changes.

I thought of using a mousedown event, but this doesn’t work since the user might click to expand something and I do not want to save the state of the treeview since nothing changed. One way to make this work would be to calculate the dimensions of each checkbox location and then check the mousedown’s click coordinates, but I would like to avoid doing this as it would not be easy since I have nested nodes so the check boxes have a few different columns they could be.

Another way to think of this is I want to turn groups of events into actions. So one action would represent the User’s first action, and all the simulated actions that followed until control is returned to the user.

Another thought, maybe I could do something with window focusing or control. For instance if the window is not focused while simulating, I could just save on the focus change if it would occur during a User’s action of checking a tree node’s checkbox.

Additional info

The simulated checkbox clicks are invoked by code such as:

e.Node.Checked = false;

This triggers the event:
private void tree_AfterCheck(object sender, System.Windows.Forms.TreeViewEventArgs e)

When a user clicks a node, this AfterCheck event triggers. I want to save the state of the tree here. But inside the AfterCheck event, there are cases that check other nodes causing the AfterCheck event to trigger again n times, but this time the check for the checkbox was simulated.

Systems.Windows.Forms.TreeView is the sender object in all cases.

  • 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-06-15T20:19:15+00:00Added an answer on June 15, 2026 at 8:19 pm

    Have you tried the CheckBox.Click event?

    This would make it easy to tell that the user was clicking to make the change.

    You could also use a flag to indicate that any events raised would be because the method was making the change. Since this is a windows form, the user will not be able to check another box until your process has finished (so there is no raceway condition).

    /// <summary>
    /// Flag which can be accessed by the checkboxes which indicates if the program is making the change or the user is.
    /// </summary>
    bool programmaticallySettingChecks { get; set; }
    
    protected void FlagExample()
    {
        CheckBox[] chToCheck = new CheckBox[10];        //Collection of checkboxes to set the Checked property on.
    
        programmaticallySettingChecks = true;
    
        for (int i = 0; i < chToCheck.Length; i++)
        {
            chToCheck[0].Checked = true;
        }
    
        programmaticallySettingChecks = false;
    }
    
    protected void Check_Clicked(Object sender, EventArgs e)
    {
        if (programmaticallySettingChecks)
        {
            //do things which are done if setting programmatically.
        }
        else
        {
            //Do things which are done if user sets.
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TreeView with a parent node and two children node. Each of
I am trying to make a treeView that have items in the following order.
I have a node on a TreeView that I populate manually and want to
I have a TreeView and a list view controls that both supports edit their
Basically in the treeview, I have a list of items, if the item is
I have a treeview which contains, per node, a key and text. However, there
I have a treeview that contains icons. The icons are ugly. and by ugly
I have a TreeView that launches a new window when each of its TreeViewItems
I have a treeview that is bound to a collection and each item in
I have a TreeView that is bound to a XmlDataSource control. I've added some

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.