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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:16:06+00:00 2026-05-13T14:16:06+00:00

I’ve added checkboxes to my treeview, and am using the AfterSelect event (also tried

  • 0

I’ve added checkboxes to my treeview, and am using the AfterSelect event (also tried AfterChecked).

My tree view is like this

1 State
1.1 City1
1.2 City2
1.3 City3
2 State
2.1 City1
2.2 City2
2.3 City3

etc.

I’m trying to run an event, so when a checkbox is clicked, the tag is added to an array ready for processing later. I also need to use it so if a state is clicked, it selects all the cities under that leaf.

treeSections.AfterSelect += node_AfterCheck;

private void node_AfterCheck(object sender, TreeViewEventArgs e)
{
    MessageBox.Show("testing");
}

The above code works on the treeview if it has no heirarchy. But don’t work on the treeview with the states and cities unless the text/label for each leaf is double clicked.

Any ideas?

  • 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-13T14:16:07+00:00Added an answer on May 13, 2026 at 2:16 pm

    I suggest using the combination of TreeView.NodeMouseClick and TreeView.KeyUp events… the click event will provide you the clicked node via event args and with the keyup you can use the currently selected node. Follow the example below…

    //This is basic - you may need to modify logically to fit your needs
    void ManageTreeChecked(TreeNode node)
    {
       foreach(TreeNode n in node.Nodes)
       {
          n.Checked = node.Checked;
       }
    }
    
    private void convTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
    {
       ManageTreeChecked(e.Node);
    }
    private void convTreeView_KeyUp(object sender, KeyEventArgs e)
    {
       if (e.KeyCode == Keys.Space)
       {
          ManageTreeChecked(convTreeView.SelectedNode);
       }
    }
    

    Using the node given each event you can now cycle through the Nodes collection on that node and modify it to be checked/unchecked given the status of the checked status of the node you acted upon.

    You can even get fancy enough to uncheck a parent node when all child nodes are unchecked. If you desire a 3-state treenode (All Checked, Some Checked and None Checked) then you have to create it or find one that has been created.

    Enjoy, best of luck.

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

Sidebar

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.