Back to Devexpress

TreeList.GetAllCheckedNodes() Method

windowsforms-devexpress-dot-xtratreelist-dot-treelist-e12d0d79.md

latest4.8 KB
Original Source

TreeList.GetAllCheckedNodes() Method

Returns the list of checked nodes.

Namespace : DevExpress.XtraTreeList

Assembly : DevExpress.XtraTreeList.v25.2.dll

NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList

Declaration

csharp
public List<TreeListNode> GetAllCheckedNodes()
vb
Public Function GetAllCheckedNodes As List(Of TreeListNode)

Returns

TypeDescription
List<TreeListNode>

The list of checked nodes.

|

Remarks

A node is checked if its TreeListNode.Checked property is true. The list returned by the GetAllCheckedNodes method does not include nodes with the indeterminate check state.

Example

The following code shows how to retrieve checked nodes using the TreeList.GetAllCheckedNodes method, and modify their values.

csharp
List<TreeListNode> list = treeList1.GetAllCheckedNodes();
foreach (TreeListNode node in list) {
    decimal budget = Convert.ToDecimal(node["BUDGET"])*1.1m;
    node["BUDGET"] = budget;
}
vb
Dim list As List(Of TreeListNode) = treeList1.GetAllCheckedNodes()
For Each node As TreeListNode In list
    Dim budget As Decimal = Convert.ToDecimal(node("BUDGET")) * 1.1D
    node("BUDGET") = budget
Next

Example

The following example shows how to use a node iterator to retrieve unchecked TreeList nodes.

csharp
using DevExpress.XtraTreeList.Nodes.Operations;

GetUncheckedNodesOperation op = new GetUncheckedNodesOperation();
treeList1.NodesIterator.DoOperation(op);
//Get the number of unchecked nodes:
int count = op.TargetNodes.Count;

//The operation class that collects unchecked nodes
class GetUncheckedNodesOperation : TreeListOperation {
    public List<TreeListNode> TargetNodes = new List<TreeListNode>();
    public GetUncheckedNodesOperation() : base() { }
    public override void Execute(TreeListNode node) {
        if (node.CheckState == CheckState.Unchecked)
            TargetNodes.Add(node);
    }
}
vb
Imports DevExpress.XtraTreeList.Nodes.Operations
Imports DevExpress.XtraTreeList.Nodes

Dim op As GetUncheckedNodesOperation = New GetUncheckedNodesOperation()
treeList1.NodesIterator.DoOperation(op)
'Get the number of unchecked nodes:
Dim count As Integer = op.TargetNodes.Count

'The operation class that collects unchecked nodes
Friend Class GetUncheckedNodesOperation
    Inherits TreeListOperation
    Public TargetNodes As List(Of TreeListNode) = New List(Of TreeListNode)()
    Public Sub New()
        MyBase.New()
    End Sub
    Public Overrides Sub Execute(ByVal node As TreeListNode)
        If node.CheckState = CheckState.Unchecked Then
            TargetNodes.Add(node)
        End If
    End Sub
End Class

See Node Checking - Checkboxes and Radio Buttons to learn more.

Example

The following code shows how to retrieve checked nodes using the TreeList.GetAllCheckedNodes method, and modify their values.

csharp
List<TreeListNode> list = treeList1.GetAllCheckedNodes();
foreach (TreeListNode node in list) {
    decimal budget = Convert.ToDecimal(node["BUDGET"])*1.1m;
    node["BUDGET"] = budget;
}
vb
Dim list As List(Of TreeListNode) = treeList1.GetAllCheckedNodes()
For Each node As TreeListNode In list
    Dim budget As Decimal = Convert.ToDecimal(node("BUDGET")) * 1.1D
    node("BUDGET") = budget
Next

See Also

Checked

Node Checking - Checkboxes and Radio Buttons

TreeList Class

TreeList Members

DevExpress.XtraTreeList Namespace