Check all nodes

4 posts, 0 answers
  1. Pierre-Olivier Grangaud
    Pierre-Olivier Grangaud  avatar
    58 posts
    Member since:
    Sep 2006

    Posted 21 May 2007 Link to this post

    Hello,

    I want to check all the nodes in my treeview. I searched if a method to do it existed but I haven't found anything.
    Should I do a recursive loop on my node collection to check all the nodes of my treeview ?

    I know it's the first version of the WinForm Treeview but a method to check or uncheck all the nodes could be useful.
    There is also some nice methods available in your ASP.NET RadTreeView that should be included in the WinForm version like the GetAllNodes method. It's only an example I haven't listed all the difference.

    I'm waiting for your answer and feedback
    Best regards

  2. Veljko Janjic
    Veljko Janjic avatar
    20 posts
    Member since:
    Nov 2005

    Posted 22 May 2007 Link to this post

    Follow up on this topic,

    I can't find any event which fires when node is checked.
    Is there any ?


    Thanks in advance.

    Veljko
    www.buildingexplorer.com
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Pierre-Olivier Grangaud
    Pierre-Olivier Grangaud  avatar
    58 posts
    Member since:
    Sep 2006

    Posted 22 May 2007 Link to this post

    I noticed that there is also no method or property to get all the checked nodes like with the ASP.NET Treeview.

    Will you enhance the checkbox features soon ?

    Best regards
  5. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 22 May 2007 Link to this post

    Hi Veljko Janjic,

    At present we do not have such event, but it will be added in an upcoming release of RadControls for WinForms.

    We've implemented the action model in our RadTreeView so if you would like to do something specific you could create a new action and then call the ExecuteActionOnTree method of RadTreeView. The following example demonstrates how to check all of the nodes in a treeView using the already mentioned action model:

    1) The first step is to  create a new action called PropertyAction.
     
    public class PropertySetAction : NodeAction 
        object propertyValue; 
        string propertyName; 
     
        public PropertySetAction(object propertyValue, string propertyName) 
        { 
            this.propertyValue = propertyValue; 
            this.propertyName = propertyName; 
        } 
     
        public override void Execute(RadTreeNode node) 
        { 
            try 
            { 
                Type type = typeof(RadTreeNode); 
                PropertyInfo myPropertyInfo = type.GetProperty(this.propertyName); 
     
            myPropertyInfo.SetValue(node, this.propertyValue, null); 
            } 
            catch(Exception e ) 
            { 
                MessageBox.Show(e.Message); 
            } 
        } 
     
    2) The second step is to call the ExecuteActionOnTree method.
    this.radTreeView1.ExecuteActionOnTree(this.radTreeView1, this.radTreeView1.Nodes, -1, new PropertySetAction(true"Checked")); 
         
     
    As you can see the parameters which you need to pass are an instance of RadTreeView, the nodes collection of that treeView, the level of the nodes which would be affected from that action, and the specific action which would be executed on that treeView.

    I hope this helps. I will be very happy if you continue to share your interesting ideas on new features and enhancements in our RadTreeView. Thank you for your valuable feedback.


    All the best,
    Ray
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top