Click here to Skip to main content
13,297,406 members (71,358 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


5 bookmarked
Posted 19 Aug 2011

Select only one node in Treeview

, 21 Aug 2011
Rate this:
Please Sign up or sign in to vote.
Select only one node in Treeview
If you want to check Treeview control's only one node for each root node, you can use this:

private void treeview1_AfterCheck(object sender, TreeViewEventArgs e)
    if (e.Node.Checked)
private void DiselectParentNodes(TreeNode parent)
    while (parent != null)
        if (parent.Checked)
            parent.Checked = false;
        parent = parent.Parent;
private void DiselectChildNodes(TreeNodeCollection childes)
    foreach (TreeNode oneChild in childes)
        if (oneChild.Checked)
            oneChild.Checked = false;


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Vano Maisuradze
Georgia Georgia
No Biography provided

You may also be interested in...


Comments and Discussions

BugNot working code Pin
Martin Křížek6-Jan-16 4:00
memberMartin Křížek6-Jan-16 4:00 
SuggestionFor checking Single node at a time in entire tree Pin
AshishAgrawal12326-Aug-14 21:21
memberAshishAgrawal12326-Aug-14 21:21 
GeneralThis code will uncheck all 'ancestor' nodes of a given TreeN... Pin
BillWoodruff22-Aug-11 15:52
memberBillWoodruff22-Aug-11 15:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171207.1 | Last Updated 21 Aug 2011
Article Copyright 2011 by Vano Maisuradze
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid