Click here to Skip to main content
11,642,381 members (61,825 online)
Click here to Skip to main content

Tagged as

Select only one node in Treeview

, 21 Aug 2011 CPOL 26.1K 5
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
Software Developer (Senior)
Georgia Georgia
No Biography provided

You may also be interested in...

Comments and Discussions

SuggestionFor checking Single node at a time in entire tree Pin
AshishAgrawal12326-Aug-14 20:21
memberAshishAgrawal12326-Aug-14 20:21 
GeneralThis code will uncheck all 'ancestor' nodes of a given TreeN... Pin
BillWoodruff22-Aug-11 14:52
memberBillWoodruff22-Aug-11 14:52 

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

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

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