This is a migrated thread and some comments may be shown as answers.

Check all nodes

3 Answers 388 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Pierre-Olivier Grangaud
Top achievements
Rank 2
Pierre-Olivier Grangaud asked on 21 May 2007, 04:23 PM
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

3 Answers, 1 is accepted

Sort by
0
Veljko Janjic
Top achievements
Rank 1
answered on 22 May 2007, 05:25 AM
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
0
Pierre-Olivier Grangaud
Top achievements
Rank 2
answered on 22 May 2007, 09:14 AM
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
0
Boyko Markov
Telerik team
answered on 22 May 2007, 05:11 PM
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
Tags
Treeview
Asked by
Pierre-Olivier Grangaud
Top achievements
Rank 2
Answers by
Veljko Janjic
Top achievements
Rank 1
Pierre-Olivier Grangaud
Top achievements
Rank 2
Boyko Markov
Telerik team
Share this question
or